[generate/supervision] mails en utf-8
Ignore-this: cb2ea9ee2f6e37c135e515d752934446 L'expérience montre qu'encoder en utf-8 est davantage fail proof (quite à écrire de l'apf4242) On utilise email.mime pour ne pas trop mettre les mains dans le cambouis (typiquement, il me manquait un content-transfer-encoding: 8bit avec l'ancienne méthode) darcs-hash:20130120231043-28565-b17c7fd4c90e4c2c7d0a34a2d1f0dde8be1e2864.gz
This commit is contained in:
parent
7141c2c7da
commit
f867321e39
1 changed files with 6 additions and 5 deletions
|
@ -9,6 +9,7 @@ from ldap_crans import smtpserv, crans_ldap, Machine, Adherent, Club
|
||||||
from whos import machine_details, adher_details, club_details
|
from whos import machine_details, adher_details, club_details
|
||||||
from gen_confs import gen_config
|
from gen_confs import gen_config
|
||||||
from affich_tools import cprint, OK, anim
|
from affich_tools import cprint, OK, anim
|
||||||
|
from email.mime.text import MIMEText
|
||||||
|
|
||||||
class mail:
|
class mail:
|
||||||
"""
|
"""
|
||||||
|
@ -73,11 +74,11 @@ Content-Transfer-Encoding: 8bit
|
||||||
texte = re.sub('\x1b\[1;([0-9]|[0-9][0-9])m','',texte)
|
texte = re.sub('\x1b\[1;([0-9]|[0-9][0-9])m','',texte)
|
||||||
|
|
||||||
conn=smtplib.SMTP(smtpserv)
|
conn=smtplib.SMTP(smtpserv)
|
||||||
conn.sendmail(self.From, self.To , \
|
msg = MIMEText(texte.encode('utf-8'), _charset='utf-8')
|
||||||
self.mail_template % { 'From' : self.From,
|
msg['From'] = self.From
|
||||||
'To' : ','.join(self.To),
|
msg['To'] = ','.join(self.To)
|
||||||
'Subject' : self.Subject,
|
msg['Subject'] = self.Subject
|
||||||
'Text' : texte.encode('iso8859-15') } )
|
conn.sendmail(self.From, self.To , msg.as_string())
|
||||||
conn.quit()
|
conn.quit()
|
||||||
print OK
|
print OK
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue