Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import smtplib
- from datetime import datetime
- import asyncore
- from smtpd import SMTPServer
- class EmlServer(SMTPServer):
- no = 0
- def process_message(self, peer, mailfrom, rcpttos, data):
- gmail_user = 'lab.performance.reporter@gmail.com'
- gmail_password = 'reporter123'
- data = data.replace('\\n', '\n')
- print 'Sending email...'
- try:
- server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
- server.ehlo()
- server.login(gmail_user, gmail_password)
- server.sendmail(mailfrom, rcpttos, data)
- server.quit()
- print 'Email sent...'
- except Exception as ex:
- print ex
- print 'Something went wrong...'
- def run():
- foo = EmlServer(('localhost', 5000), None)
- try:
- asyncore.loop()
- except KeyboardInterrupt:
- pass
- if __name__ == '__main__':
- run()
Add Comment
Please, Sign In to add comment