12345678910111213141516171819202122232425262728 |
- import smtplib
- import sys
- if len(sys.argv) != 4:
- print "Usage %s [from] [to] [subject]"
- sys.exit(10)
- from_addr=sys.argv[1]
- to_addr=sys.argv[2]
- subject=sys.argv[3]
- # Import the email modules we'll need
- from email.mime.text import MIMEText
- # Create a text/plain message
- msg = MIMEText("Test email")
- # me == the sender's email address
- # you == the recipient's email address
- msg['Subject'] = subject
- msg['From'] = from_addr
- msg['To'] = to_addr
- # Send the message via our own SMTP server, but don't include the
- # envelope header.
- s = smtplib.SMTP('localhost')
- s.sendmail(from_addr, to_addr, msg.as_string())
- s.quit()
|