Files
storage_fresco/generatemails.py
2019-05-24 11:10:22 +00:00

31 lines
796 B
Python

#!/usr/bin/python
import os
import smtplib
from time import sleep
sender = 'lvr@gustavogusto.com'
receivers = ['w.niedersetz@gustavogusto.com']
testmessage = """From: ELA LVR <lvr@gustavogusto.com>
To: Waldemar Niedersetz <w.niedersetz@gustavogusto.com>
Subject: SMTP e-mail test
This is a test e-mail message.
"""
mailpath = '/opt/mails'
if __name__ == "__main__":
while 1:
files = os.listdir (mailpath)
for fname in files:
f = open ("/opt/mails/" + fname, "r")
message = f.read ()
f.close ()
try:
smtpObj = smtplib.SMTP('104.47.10.36') #, 587)
smtpObj.sendmail(sender, receivers, message)
os.remove ("/opt/mails/" + fname)
print "Successfully sent email"
except:
print "Error: unable to send email"
sleep (2)