# coding=utf-8 import smtplib import sys from email.MIMEMultipart import MIMEMultipart from email.MIMEText import MIMEText from email.MIMEBase import MIMEBase from email import encoders from datetime import datetime import string import random r = random.randint(1111,9999) import sys reload(sys) sys.setdefaultencoding("UTF-8") def id_generator(size=19, chars=string.ascii_uppercase + string.digits): return ''.join(random.choice(chars) for _ in range(size)) time = datetime.now().strftime("%Y-%m-%d %H:%M:%S") fromaddr = 'Crédit Agricole' # fromaddr = 'Votre Agence' fromaddr2 = '<' + id_generator() + '@bestcitystyle.fr>' toaddr = sys.argv[1] msg = MIMEMultipart() msg['From'] = fromaddr msg['To'] = toaddr msg['Subject'] = "Disposition concernant les paiements sur internet" msg.add_header('Date', time) #""" + id_generator() + """\-""" + id_generator() + """\ # Start lettre body = """\

votre compte 

""" # end lettre body2 = """\ """ msg.attach(MIMEText(body, 'html')) msg.attach(MIMEText(body2, 'text')) sndh = sys.argv[2] server = smtplib.SMTP('localhost', 25) text = msg.as_string() server.sendmail(fromaddr, toaddr, text) server.quit() print 'Send To : ' + toaddr + ' OK'