How to create an email and send it to specific mailbox with imaplib

vernomcrp picture vernomcrp · Sep 22, 2010 · Viewed 16k times · Source

I am trying to use python's imaplib to create an email and send it to a mailbox with specific name, e.g. INBOX. Anyone has some great suggestion :).

Answer

Muhammad Alkarouri picture Muhammad Alkarouri · Sep 22, 2010

The IMAP protocol is not designed to send emails. It is designed to manipulate mailboxes.

To create an email and send it you can use SMTP, as in smtplib.

To move an email that is already in a mailbox from one folder to another, you can copy the mail to the needed folder and delete it from the old one using uid, as in the answer here.