
上QQ阅读APP看书,第一时间看更新
How it works...
There are two key steps in the scripts—the generation of the message, and the sending.
The message needs to contain mainly the To and From email addresses, as well as the Subject. If the content is pure text, as in this case, calling .set_content() is enough. The whole message can then be sent.
It is technically possible to send an email from a different email than the account used to send it. This is discouraged, though, as it can be considered by your email provider as trying to impersonate a different email. You can use the reply-to header as a way of allowing answering to a different account.
Sending the email requires you to connect to the specified server and start an SMPT connection. SMPT is the standard for email communication.
The steps are quite straightforward—configure the server, log into it, send the prepared message, and quit.
If you need to send more than one message, you can log in, send multiple emails, and then quit, instead of connecting each time.