How do I build an smtp client in python?
Create mails (possibly with multipart attachments) using email .
The package
is a library for managing email messages including MIME and other RFC 2822-based documents.
Send mail using smtplib
The module
smtplib
defines an SMTP client session object that can be used to send mail to any Internet computer using an SMTP or ESMTP listener.
If you are interested in viewing a remote mailbox (for example, to see if a sent message has arrived), you need a mail service that is accessible through a known protocol. A popular example is a imaplib
module that implements a IMAP4
protocol . IMAP
supportedgmail
.
This (
imaplib
) module defines three classes, IMAP4, IMAP4_SSL, and IMAP4_stream, which encapsulate the connection to an IMAP4 server and implement a large subset of the IMAP4rev1 client protocol as defined in RFC 2060. It is backward compatible with IMAP4 (RFC 1730), but note that the command STATUS is not supported in IMAP4.
a source to share
If you want the Python standard library to do your job (recommended!) Use smtplib . To see if sending mail works, just open your inbox;)
If you want to implement the protocol yourself (is it homework?), Then read up on SMTP protocol and use socket for example .
a source to share
Depends on what you mean by "received". It is possible to verify that the message was "delivered" to the server, but there is no reliable 100% guarantee that it actually ended up in the mailbox. smtplib will throw an exception on certain conditions (for example, the remote end user of the reports was not found), but it is also common for the remote end to receive mail and then either filter it or send a rejection notification at a later time.
a source to share