|
|
@@ -1,15 +1,15 @@
|
|
|
-#!/usr/bin/python2
|
|
|
+#!/usr/bin/python3
|
|
|
# -*- coding: utf-8 -*-
|
|
|
import smtplib
|
|
|
+import pymysql
|
|
|
+import sys
|
|
|
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'
|
|
|
+ noreplypass = "contraseñaparacandelaria"
|
|
|
|
|
|
|
|
|
msg = MIMEMultipart('alternative')
|
|
|
@@ -32,7 +32,8 @@ def sendmail(target, message, subject):
|
|
|
def populate(tpl, data):
|
|
|
out = ""
|
|
|
for line in tpl.split("\n"):
|
|
|
- for k,v in data.iteritems():
|
|
|
+ #for k,v in data.iteritems():
|
|
|
+ for k,v in data.items():
|
|
|
if k in line:
|
|
|
line = line.replace("{{%s}}" % k , data[k])
|
|
|
|
|
|
@@ -40,12 +41,31 @@ def populate(tpl, data):
|
|
|
|
|
|
return out
|
|
|
|
|
|
-DATA = {
|
|
|
- "HASH": "254bdbda00d73f8645d5d4e6f1ef2c3e9525f2fda387148a33b451c88c25"
|
|
|
-}
|
|
|
+_id = 1
|
|
|
+_id = 163
|
|
|
+
|
|
|
+DB = "EBA_STOCK"
|
|
|
+USER = "root"
|
|
|
+PASSWORD = "howdoiturnthison"
|
|
|
+
|
|
|
+conn = pymysql.connect(unix_socket='/var/run/mysqld/mysqld.sock', user=USER, passwd=PASSWORD, db=DB,cursorclass=pymysql.cursors.DictCursor)
|
|
|
+# print("pls no")
|
|
|
+# sys.exit(1)
|
|
|
+cur = conn.cursor()
|
|
|
+# cur.execute("SELECT nombre,apellido,mail,hash FROM clientes where id=%s and mail like '%%@%%'", (_id,))
|
|
|
+# cur.execute("SELECT nombre,apellido,mail,hash FROM clientes where tipo=1 and mail like '%%@%%'")
|
|
|
+cur.execute("SELECT nombre,apellido,mail,hash FROM clientes where tipo=1 and mail like '%%pouso%%'")
|
|
|
+clientes = cur.fetchall()
|
|
|
+for cliente in clientes:
|
|
|
+ print(cliente)
|
|
|
+ DATA = { }
|
|
|
+ DATA["HASH"] = cliente["hash"]
|
|
|
+ target = cliente["mail"]
|
|
|
+ #target = "mpetrigliano@leticiapepe.com.ar"
|
|
|
+ message = open("mailtemplate.html").read()
|
|
|
+ subject = "Link pedidos ESPECIFICOS Buenos Aires"
|
|
|
+ # print(populate(message, DATA))
|
|
|
+ sendmail(target, populate(message, DATA), subject)
|
|
|
+ # sendmail("davidventura27@gmail.com", populate(message, DATA), subject)
|
|
|
+ # sendmail("especificosba@gmail.com", populate(message, DATA), subject)
|
|
|
|
|
|
-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)
|