Email Log en Python

#!/usr/bin/python
### This script send the content of the logfile
import smtplib
import os
import sys
from email.MIMEText import MIMEText
def sendTextMail(text):
fromaddr = “Moi
liste_destinataires=[’monchef@mondedomaine.com’]
mail = MIMEText(text)
mail[’From’] = fromaddr
mail[’Subject’] = “BUILDAUTO”
smtp = smtplib.SMTP()
smtp.connect()
for d in liste_destinataires:
smtp.sendmail(fromaddr,d,mail.as_string())
smtp.close()
def main():
logfile = sys.argv[1]
f=open(logfile, “r”)
corps = “”"\
Hello,
That is the result of the engine compilation
“”"
for i in f:
corps+=i
corps+=”"”\
PS : Please do not respond
“”"
f.close()
sendTextMail(corps)
if __name__ == ‘__main__’:
main()
