| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- #!/usr/bin/python2
- # -*- coding: utf-8 -*-
- import smtplib
- from email.mime.multipart import MIMEMultipart
- from email.mime.text import MIMEText
- def sendmail(target, message, subject):
- noreply = 'consultas@especificosba.com.ar'
- #noreplypass = "contraseñaparacandelaria".encode("ascii","ignore")
- #noreplypass = noreplypass.decode("ascii")
- noreplypass = 'contraseñaparacandelaria'
-
- msg = MIMEMultipart('alternative')
- msg['Subject'] = subject
- msg['From'] = noreply
- msg['to'] = target
- msg.attach(MIMEText(message,'html'))
- s = smtplib.SMTP('mail.especificosba.com.ar:587')
- s.ehlo()
- s.starttls()
- #print("tls'd", noreply, noreplypass)
- s.login(noreply, noreplypass)
- try:
- s.sendmail(noreply, target, msg.as_string())
- except Exception:
- print("Error al enviar la consulta")
- finally:
- s.quit()
- def populate(tpl, data):
- out = ""
- for line in tpl.split("\n"):
- for k,v in data.iteritems():
- if k in line:
- line = line.replace("{{%s}}" % k , data[k])
- out += line + "\n"
-
- return out
- DATA = {
- "HASH": "254bdbda00d73f8645d5d4e6f1ef2c3e9525f2fda387148a33b451c88c25"
- }
- message = open("mailtemplate.html").read()
- subject = "Link pedididos ESPECIFICOS Buenos Aires"
- target = "adriana.garcia.cc@gmail.com"
- target = "davidventura27@gmail.com"
- sendmail(target, populate(message, DATA), subject)
|