Hardware Reference
In-Depth Information
Listing 13-5 continued
“””
import sys
import smtplib
from email.mime.text import MIMEText
def SendEmail(MessageText):
#enter the e-mail account username between the quotes
smtp_user = “”
#enter the e-mail account password between the quotes
smtp_pass = “”
#sys.argv[1] is the 1st parameter that is passed to
#this program and it contains the text for the body
#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(“”,587)
s.ehlo()
s.starttls()
s.ehlo()
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()
Search WWH ::




Custom Search