1. Create file sendmail.py
2. Insert Code
- #!/usr/bin/python
- import smtplib
- from smtplib import SMTP
- recipients = ['suwit.jph@gmail.com', 'suwit_jph@hotmail.co.th']
- def send_email (message, status):
- fromaddr = 'scivalve.suwit@gmail.com'
- server = SMTP('smtp.gmail.com:587')
- server.ehlo()
- server.starttls()
- server.ehlo()
- server.login('scivalve.suwit@gmail.com', 'password')
- server.sendmail(fromaddr, recipients, 'Subject: %s\r\n%s' % (status, message))
- server.quit()
- send_email("Test","Test send mail")
3. Test Run Command.
- ./sendmail.py
Example : http://stackoverflow.com/questions/2050 ... -addresses
No comments:
Post a Comment