[TriEmbed] Pi email using python example
Alex Davis
alexd at matrixwide.com
Wed Nov 11 12:46:23 CST 2015
Here’s another way to send email from anything running python using secure SMTP:
Use smtplib and email.mime.text:
libraries and variables:
import smtplib
from email.mime.text import MIMEText
mailUser = <your mail account>
mailPwd = <your mail password>
mailTo = <recipient>
example sending an email via secure SMTP port 587 to my fastmail.com account:
msg = MIMEText('CPM was: %d' % (total))
msg['Subject'] = 'Radiation Threshold Alert'
msg['From'] = mailUser
msg['To'] = mailTo
server = smtplib.SMTP('mail.messagingengine.com:587')
server.ehlo_or_helo_if_needed()
server.starttls()
server.ehlo_or_helo_if_needed()
server.login(mailUser,mailPwd)
server.sendmail(mailUser, mailTo, msg.as_string())
server.quit()
Gone are the days of SMTP on port 25...
|\ | (¯ \/ |¯\ |V| |\ ¯|¯ |¯) | \/ | | | |¯\ (¯ /¯ /\ |V|
|-||_ (_ /\ |_/ @| | |-| | | \ | /\ |^| | |_/ (_ . \_ \/ | |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 495 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://mail.triembed.org/pipermail/triembed_triembed.org/attachments/20151111/18d8a879/attachment.sig>
More information about the TriEmbed
mailing list