Advertisement
Guest User

Untitled

a guest
Jul 4th, 2016
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.03 KB | None | 0 0
  1. ------- Views.py ---------------
  2. @csrf_exempt
  3. def counter(request):
  4. template = "test.html"
  5. return render(request, template)
  6.  
  7. @csrf_exempt
  8. def enviar_emails(request):
  9. email = request.POST.get('emails', None)
  10. segundos = request.POST.get('segundos', 15)
  11. if not email == None:
  12. email = str(email).split(',')
  13. SMTPserver = 'smtpout.secureserver.net'
  14. sender = 'next_argentina@bestjet.com.ar'
  15.  
  16. USERNAME = "contactos@bestjet.com.ar"
  17. PASSWORD = "adrian66"
  18.  
  19. # typical values for text_subtype are plain, html, xml
  20. text_subtype = 'html'
  21.  
  22.  
  23. content="""
  24. <div style="text-align:center">
  25. <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>
  26. <br><b><span lang="EN-US" style="font-size:14.0pt;font-family:Tahoma,sans-serif">UNICO IMPORTADOR</span></b>
  27. <br><span lang="EN-US" style="font-size:11.0pt;font-family:Calibri,sans-serif;color:#1f497d"></span>
  28. <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>
  29. <b><span style="font-size:14.0pt;font-family:Calibri,sans-serif"></span></b>
  30. <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>
  31. <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>
  32. <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>
  33. <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>
  34. <br><span lang="EN-US" style="font-size:11.0pt;font-family:Calibri,sans-serif;color:#1f497d">&nbsp;</span>
  35. <div align="center">
  36. <table border="0" cellspacing="0" cellpadding="0" width="1380" style="width:690.0pt">
  37. <tbody><tr>
  38. <td style="padding:0cm 0cm 0cm 0cm"><img src="http://i.imgur.com/flXPoBC.jpg" alt="Publicidad Bestjet" tabindex="0"></td>
  39. </tr></tbody>
  40. </table>
  41. </div>
  42. </div>
  43. """
  44.  
  45. subject="Importadora Next Argentina - Insumos Bestjet"
  46.  
  47. import sys
  48. import os
  49. import re
  50.  
  51. from smtplib import SMTP # use this for standard SMTP protocol (port 25, no encryption)
  52.  
  53. from email.mime.text import MIMEText
  54.  
  55. try:
  56. msg = MIMEText(content, text_subtype)
  57. msg['Subject']= subject
  58. msg['From'] = sender # some SMTP servers will do this automatically, not all
  59.  
  60. conn = SMTP(SMTPserver)
  61. conn.set_debuglevel(False)
  62. conn.login(USERNAME, PASSWORD)
  63. try:
  64. for destination in email:
  65. conn.sendmail(sender, destination, msg.as_string())
  66. time.sleep(segundos)
  67. #return HttpResponse(destination) #Esto rompe todo
  68. finally:
  69. conn.quit()
  70.  
  71. except Exception as exc:
  72. sys.exit( "mail failed; %s" % str(exc) )
  73.  
  74. return HttpResponse(email)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement