|
|
|
![]() |
|
Strumenti |
![]() |
#1 |
Senior Member
Iscritto dal: Dec 2005
Città: Istanbul
Messaggi: 1817
|
Python, email e charset
Sto cercando di creare delle email tramite python.
Come da documentazione procedo piu' o meno nel seguente modo: Codice:
from email import MIMEText body = "Contenuto dell'email" msg = MIMEText( body ) # ... impostazione dei vari header ... raw = msg.as_string() Invariabilmente ottengo un UnicodeEncodeError. Io ovviamente per evitare questo specifico come encoding "utf-8", ma non da il risultato sperato: Codice:
from email import MIMEText body = u"Questo è il contenuto dell'email" msg = MIMEText( body, "plain", "utf-8" ) # ... impostazione dei vari header ... raw = msg.as_string() ![]() L'unico modo che ho trovato per forzare l'uso di utf-8 è quello di forzarlo come encoding di default in sitecustomize.py... ma direi che non è proprio il massimo ![]() Qualcuno ha già avuto a che fare con questi problemi ?
__________________
One of the conclusions that we reached was that the "object" need not be a primitive notion in a programming language; one can build objects and their behaviour from little more than assignable value cells and good old lambda expressions. —Guy Steele |
![]() |
![]() |
![]() |
Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 21:19.