Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------- Views.py ---------------
- @csrf_exempt
- def counter(request):
- template = "test.html"
- return render(request, template)
- @csrf_exempt
- def enviar_emails(request):
- email = request.POST.get('emails', None)
- segundos = request.POST.get('segundos', 15)
- if not email == None:
- email = str(email).split(',')
- SMTPserver = 'smtpout.secureserver.net'
- sender = 'next_argentina@bestjet.com.ar'
- USERNAME = "contactos@bestjet.com.ar"
- PASSWORD = "adrian66"
- # typical values for text_subtype are plain, html, xml
- text_subtype = 'html'
- content="""
- <div style="text-align:center">
- <b><span lang="EN-US" style="font-size:14.0pt;font-family:Tahoma,sans-serif">TONERS HP SAMSUNG, BROTHER y CARTUCHOS EPSON BESTJET</span></b>
- <br><b><span lang="EN-US" style="font-size:14.0pt;font-family:Tahoma,sans-serif">UNICO IMPORTADOR</span></b>
- <br><span lang="EN-US" style="font-size:11.0pt;font-family:Calibri,sans-serif;color:#1f497d"></span>
- <br><b><span style="font-size:14.0pt;font-family:Calibri,sans-serif;color:#1f497d">HP 612/285U/278/435/436/CF283/F280/255/505U/6511/364/2610/7553/613U/539U/092/942U/310/540</span></b>
- <b><span style="font-size:14.0pt;font-family:Calibri,sans-serif"></span></b>
- <br><b><span style="font-size:14.0pt;font-family:Calibri,sans-serif;color:#1f497d">Samsung 101/104/105/108/109/111/115/116/2010/2250/2850/4216</span></b>
- <br><b><span lang="EN-US" style="font-size:14.0pt;font-family:Calibri,sans-serif;color:#1f497d">Brother 360/450/650/750/1060</span></b>
- <br><b><span lang="EN-US" style="font-size:14.0pt;font-family:Calibri,sans-serif;color:#1f497d">DRUM BROTHER 360/420/620/1060</span></b>
- <br><b><span lang="EN-US" style="font-size:14.0pt;font-family:Calibri,sans-serif;color:#1f497d">EPSON 195 (Compatible con 195/196/197)</span></b>
- <br><span lang="EN-US" style="font-size:11.0pt;font-family:Calibri,sans-serif;color:#1f497d"> </span>
- <div align="center">
- <table border="0" cellspacing="0" cellpadding="0" width="1380" style="width:690.0pt">
- <tbody><tr>
- <td style="padding:0cm 0cm 0cm 0cm"><img src="http://i.imgur.com/flXPoBC.jpg" alt="Publicidad Bestjet" tabindex="0"></td>
- </tr></tbody>
- </table>
- </div>
- </div>
- """
- subject="Importadora Next Argentina - Insumos Bestjet"
- import sys
- import os
- import re
- from smtplib import SMTP # use this for standard SMTP protocol (port 25, no encryption)
- from email.mime.text import MIMEText
- try:
- msg = MIMEText(content, text_subtype)
- msg['Subject']= subject
- msg['From'] = sender # some SMTP servers will do this automatically, not all
- conn = SMTP(SMTPserver)
- conn.set_debuglevel(False)
- conn.login(USERNAME, PASSWORD)
- try:
- for destination in email:
- conn.sendmail(sender, destination, msg.as_string())
- time.sleep(segundos)
- #return HttpResponse(destination) #Esto rompe todo
- finally:
- conn.quit()
- except Exception as exc:
- sys.exit( "mail failed; %s" % str(exc) )
- return HttpResponse(email)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement