Chapter 5, Engaging with Email

  1. The main difference is that IMAP allows for the connection of multiple users or mail manager programs simultaneously to the same mailbox, facilitating subsequent access to the mail messages that are available on the server via web mail. POP3, on the other hand, downloads messages by deleting them from the server, and so email messages are no longer available in the server.
  2. Sendmail is the method of sending emails with the following syntax: SMTP.sendmail(from_addr, to_addrs, msg[, mail_options, rcpt_options].
  3. from email.mime.text import MIMEText.
  4. message = MIMEText(mail_msg, 'html', 'utf-8').
  5. You must first create a MimeMultipart() instance.
  6. POP3.stat(). The result is a tuple of two integers: (message count, mailbox size).
  7. The secure version of POP3() is its subclass, POP3_SSL(). It takes additional parameters, such as keyfile and certfile: mailbox = poplib.POP3_SSL(<POP3_SERVER>, <SERVER_PORT>).
  8. response, headerLines, bytes = mailbox.retr(i+1).
  9. This protocol has the advantage that, when we connect to read our mail from different devices, for example, our laptop or smartphone, we know that we can always access all of our messages, and that the mailbox will be updated. It is also interesting to preserve our privacy when we read our mail from a public or shared computer, as it does not store information on the local machine.
  10. The derived class, IMAP4_SSL().
  11. We can use the following code to open an IMAP connection:
from imapclient import IMAPClient
server = IMAPClient('imap_server', ssl=True)
server.login('user', 'password')
select_info = server.select_folder('INBOX',readonly=True)
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset