Created
May 28, 2012 11:39
-
-
Save InFog/2818715 to your computer and use it in GitHub Desktop.
Envio de e-mails para a lista de inscritos no Ação Mozilla nas Universidades Unaerp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import re | |
import smtplib | |
from email.mime.multipart import MIMEMultipart | |
from email.mime.text import MIMEText | |
from time import sleep | |
def enviar_email(destinatario): | |
origem = "[email protected]" | |
msg = MIMEMultipart('alternative') | |
msg['Subject'] = u"Ação Mozilla nas Universidades" | |
msg['From'] = origem | |
msg['To'] = destinatario | |
html = """ | |
<html> | |
<head></head> | |
<body style="font-size: 16px;"> | |
<table border="0" style="width: 100%; background-color: #0067AE"> | |
<tr> | |
<td><img src="http://dl.dropbox.com/u/6403691/firefox-logo.png" style="float: right;" /><img src="http://dl.dropbox.com/u/6403691/unaerp.jpeg" /></td> | |
</tr> | |
</table> | |
<p>Olá,</p> | |
<p>Queremos lembra-lo que amanhã é o dia da <strong>Ação Mozilla nas Universidades</strong> na Unaerp Guarujá, contamos com a sua presença! | |
<p>Endereço: Av. Dom Pedro I, 3300 - Enseada - Guarujá/SP</p> | |
<p>Informações no telefone (13) 3398-1000 e no site <a href="http://www.moz.gccsd.com.br">http://www.moz.gccsd.com.br</a></p> | |
<p>Localize-se pelo Google Maps <a href="http://va.mu/VWMM">http://va.mu/VWMM</a></p> | |
<p>Abraço,</p> | |
<p>Equipe Organizadora</p> | |
<table border="0" style="width: 100%; background-color: #0067AE"> | |
<tr> | |
<td style="text-align: right"><a style="color: #FFF; text-decoration: none" href="http://casoftweb.com.br"> | |
<img src="http://dl.dropbox.com/u/6403691/logo_casoft.png" title="CaSoft WEB" /> | |
</a></td> | |
</tr> | |
</table> | |
</body> | |
</html> | |
""" | |
htmlMSG = MIMEText(html, 'html') | |
msg.attach(htmlMSG) | |
s = smtplib.SMTP('localhost') | |
s.sendmail(origem, destinatario, msg.as_string()) | |
s.quit() | |
# Os inscritos estavam em uma lista em uma página HTML | |
inscritos = open('inscritos.html', 'r') | |
email_pattern = re.compile('([\w\-\.]+@(\w[\w\-]+\.)+[\w\-]+)') | |
for line in inscritos: | |
for match in email_pattern.findall(line): | |
print "Enviando para %s" % match[0] | |
enviar_email(match[0]) | |
sleep(3) | |
inscritos.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment