|
@@ -28,10 +28,13 @@ def sendmail(target, message, subject):
|
|
|
s.login(noreply, noreplypass)
|
|
s.login(noreply, noreplypass)
|
|
|
try:
|
|
try:
|
|
|
s.sendmail(noreply, target, msg.as_string())
|
|
s.sendmail(noreply, target, msg.as_string())
|
|
|
|
|
+ ok = True
|
|
|
except Exception:
|
|
except Exception:
|
|
|
|
|
+ ok = False
|
|
|
print("Error al enviar la consulta")
|
|
print("Error al enviar la consulta")
|
|
|
finally:
|
|
finally:
|
|
|
s.quit()
|
|
s.quit()
|
|
|
|
|
+ return ok
|
|
|
|
|
|
|
|
def populate(tpl, data):
|
|
def populate(tpl, data):
|
|
|
out = ""
|
|
out = ""
|
|
@@ -52,14 +55,17 @@ def reset(identity):
|
|
|
cur.execute("SELECT nombre,apellido,mail,hash FROM clientes where tipo=1 and mail = %s", identity)
|
|
cur.execute("SELECT nombre,apellido,mail,hash FROM clientes where tipo=1 and mail = %s", identity)
|
|
|
else: # hash
|
|
else: # hash
|
|
|
cur.execute("SELECT nombre,apellido,mail,hash FROM clientes where tipo=1 and hash = %s", identity)
|
|
cur.execute("SELECT nombre,apellido,mail,hash FROM clientes where tipo=1 and hash = %s", identity)
|
|
|
- clientes = cur.fetchall()
|
|
|
|
|
- for cliente in clientes:
|
|
|
|
|
- DATA = { }
|
|
|
|
|
- DATA["HASH"] = cliente["hash"]
|
|
|
|
|
- target = cliente["mail"]
|
|
|
|
|
- message = open("/var/www/pedido/back/mailtemplate.html").read()
|
|
|
|
|
- subject = "Link pedidos ESPECIFICOS Buenos Aires"
|
|
|
|
|
- sendmail(target, populate(message, DATA), subject)
|
|
|
|
|
|
|
+
|
|
|
|
|
+ cliente = cur.fetchone()
|
|
|
|
|
+ if cliente is None:
|
|
|
|
|
+ return False
|
|
|
|
|
+
|
|
|
|
|
+ DATA = {}
|
|
|
|
|
+ DATA["HASH"] = cliente["hash"]
|
|
|
|
|
+ target = cliente["mail"]
|
|
|
|
|
+ message = open("/var/www/pedido/back/mailtemplate.html").read()
|
|
|
|
|
+ subject = "Link pedidos ESPECIFICOS Buenos Aires"
|
|
|
|
|
+ return sendmail(target, populate(message, DATA), subject)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
if __name__ == '__main__':
|
|
|
if len(sys.argv) != 2:
|
|
if len(sys.argv) != 2:
|