Seite 1 von 1

How can I Use IMAP with Gmail

Verfasst: Dienstag 8. Oktober 2013, 11:31
von fox12345
I want to send email with IMAP.This is My code:

Code: Alles auswählen

import imaplib

sent_from = ''
sent_to = ''
msg = ''

user = ''
password = ''

server = imaplib.IMAP4_SSL('imap.gmail.com')
server.login(user,password)
server.send() #how to set send options
server.logout()


I do not understand to write balance in this.how to use the "Server.send" option in this script?
How to set (sent_from = ''/sent_to = ''/msg = '')
Help me....

Re: How can I Use IMAP with Gmail

Verfasst: Dienstag 8. Oktober 2013, 11:50
von BlackJack
@fox12345: First of all you should make sure IMAP is what you want. You can not send e-mail with the IMAP protocol. Just access remote mailboxes that *you* own, or at least have the credentials to access them.

If you really want to place an e-mail in some folder in your account, then `send()` is the wrong method. It really just sends the given raw data to the server without issuing some commands first making the server actually expect you to send it data, so it will just end in an error. Possibly the server even closes the connection if you start sending unexpected binary data.

Unless you want dealing with the IMAP protocol rather directly I would recommend the `imapclient` module which abstracts a little from the protocol. You still need to know how IMAP works to use that module.

Re: How can I Use IMAP with Gmail

Verfasst: Dienstag 8. Oktober 2013, 12:02
von fox12345
Do you know how to complete this? :roll:

Re: How can I Use IMAP with Gmail

Verfasst: Dienstag 8. Oktober 2013, 12:10
von fox12345
"Exactly i want to send email with IMAP"
So how to develop my code?

Re: How can I Use IMAP with Gmail

Verfasst: Dienstag 8. Oktober 2013, 12:15
von Sirius3
As BlackJack already said, IMAP is the wrong protocol to send emails. You have to use SMTP.

Re: How can I Use IMAP with Gmail

Verfasst: Dienstag 8. Oktober 2013, 12:32
von fox12345
But i want to use proxy to send email..but SMTP is not good to it.So i think use to IMAP..whats say about that? You have other option?

Re: How can I Use IMAP with Gmail

Verfasst: Dienstag 8. Oktober 2013, 13:08
von BlackJack
@fox12345: SMTP is the only really widespread protocol for sending e-mails. There is no other viable option. So you either find complete working code for your problem or you learn at least as much programming, Python, SMTP protocol, and proxy techniques to understand and adapt the solutions from the web search I've posted earlier.

Re: How can I Use IMAP with Gmail

Verfasst: Dienstag 8. Oktober 2013, 13:46
von fox12345
Hmmmmmmmmmmm....The IMAP protocol is not designed to send emails. It is designed to manipulate mailboxes.To create an email and send it I can use SMTP. I correct?
If that is so how to use proxy to my code?Are you have any idea. My plan is hide to sender....what to do?

Re: How can I Use IMAP with Gmail

Verfasst: Dienstag 8. Oktober 2013, 14:02
von BlackJack
@fox12345: SMTP is just for sending e-mails. Why do you want to hide from the sender? With mails sent from an automated script!? Do I smell a wannabe spammer here?

Re: How can I Use IMAP with Gmail

Verfasst: Dienstag 8. Oktober 2013, 14:23
von fox12345
he he........my dear friends I do not want to be a spammer. I am a beginner to python. As well as i like to write some useful tool to world. So I always searching about that. I want write untraceable mail sending tool. But i know it really impossible. But I want to complete half or my dream. So Now i want to make the base of my code and want to test it. So I want to Help...

Re: How can I Use IMAP with Gmail

Verfasst: Dienstag 8. Oktober 2013, 14:41
von jerch
fox12345 hat geschrieben:...I want write untraceable mail sending tool. But i know it really impossible. But I want to complete half or my dream....
Why are you dreaming about untraceable emails if you are not a spammer? No need to hide the sender if you dont do any smelly things. I question your objectives.

Re: How can I Use IMAP with Gmail

Verfasst: Dienstag 8. Oktober 2013, 20:05
von Leonidas
jerch hat geschrieben:Why are you dreaming about untraceable emails if you are not a spammer? No need to hide the sender if you dont do any smelly things. I question your objectives.
Not to excuse fox12345, but anonymity is an important asset generally. And I wish there was a really anonymous way to send E-Mail without the problem with spam and open relays. I doubt you question the motives of the Tor authors ;)

Re: How can I Use IMAP with Gmail

Verfasst: Dienstag 8. Oktober 2013, 20:20
von jerch
@Leonidas:
I totally agree with you about the importance of anonymity. But with email it is a different situation, where you approach someone - imho it is natural to introduce yourself at the door. The differrence to the www is the fact that people see their post boxes as private while a website is more like a public notice board where you can expect not to be asked for your identity.

Re: How can I Use IMAP with Gmail

Verfasst: Dienstag 8. Oktober 2013, 20:32
von BlackJack
@Leonidas: I see the value of anonymously sending e-mails as a person to another person or institution. There are providers of such services. As there is always *some* trace in mails, they have to come from *somewhere* from the senders perspective, so you need a provider you trust and the receiver (or the receiving mail provider) accepts mails from. Those services cost money or are secured against being used via scripts. For good reasons. What I find questionable here is the need for a scripted solution from someone behaving like the proverbial „script kiddie”.

Re: How can I Use IMAP with Gmail

Verfasst: Dienstag 8. Oktober 2013, 22:01
von Leonidas
BlackJack hat geschrieben:What I find questionable here is the need for a scripted solution from someone behaving like the proverbial „script kiddie”.
I agree with that assesment, so I'm completely fine with the progression of this thread :)

Re: How can I Use IMAP with Gmail

Verfasst: Mittwoch 9. Oktober 2013, 07:31
von fox12345
Thanks for everyone who take their valuable time for reply me. But I do not think that you all have give me the support for complete my messed script.What I want know is how we can use a proxy to When we send a mail through SMTP & also how it should be change in my script. I do not want to be a spammer & I really want to test it. :K Please be kind enough to help me on this matter. :?:

Re: How can I Use IMAP with Gmail

Verfasst: Mittwoch 9. Oktober 2013, 09:24
von BlackJack
@fox12345: You are thinking right — as it seems you did not manage to convince anyone this isn't a script kiddie request. I can hardly think of a convincing argument anyway.

There are ways to anonymously send e-mails: https://lmddgtfy.net/?q=anonymous%20email