Hardware Reference
In-Depth Information
#of the e-mail
msg = MIMEText(MessageText)
#enter the target e-mail address between the quotes
msg['To'] = “”
#enter the e-mail account username between the quotes
msg['From'] = “”
#enter the message subject between the quotes
msg['Subject'] = “”
#enter the SMTP server URL or IP Address between the quotes
s = smtplib.SMTP(“”)
s.login(smtp_user,smtp_pass)
s.sendmail(msg['From'], msg['To'], msg.as_string())
s.quit()
def main():
SendEmail(sys.argv[1])
if __name__ == “__main__”:
main()
Most e-mail servers use e-mail encryption, so there are two variations of the code in Listing
13-4, depending on which type of encryption is being used - transport layer security (TLS) or
SMTP SSL encryption. You can ind out what encryption is being used from your ISP, or
through trial and error. If you have a Gmail or Yahoo! account, I have included details on how
to send e-mails from their e-mail servers (providing you have an e-mail address with them).
Transport Layer Security
he code in Listing 13-5 will send an e-mail using TLS encryption.
Listing 13-5 Send E-mail Using TLS Encryption
#!/usr/bin/env python
“””
Home Automation: send e-mail using TLS encryption
For the Raspberry Pi
continued
 
Search WWH ::




Custom Search