Mercurial > moin > 1.9
changeset 56:aedb415dc3a4
more readable email notifications using quoted printable encoding
imported from: moin--main--1.5--patch-58
author | Nir Soffer <nirs@freeshell.org> |
---|---|
date | Thu, 29 Sep 2005 18:47:39 +0000 |
parents | 2932ba63d998 |
children | 546541209681 |
files | MoinMoin/util/mail.py |
diffstat | 1 files changed, 18 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/util/mail.py Thu Sep 29 18:06:32 2005 +0000 +++ b/MoinMoin/util/mail.py Thu Sep 29 18:47:39 2005 +0000 @@ -25,31 +25,41 @@ @return: (is_ok, Description of error or OK message) """ import smtplib, socket - from email.MIMEText import MIMEText - from email.Utils import formatdate + from email.Message import Message + from email.Charset import Charset, QP + from email.Utils import formatdate, make_msgid from email.Header import Header - from email.Utils import make_msgid from MoinMoin import config _ = request.getText cfg = request.cfg mail_from = kw.get('mail_from', '') or cfg.mail_from + subject = subject.encode(config.charset) - # Create a text/plain message body (see RFC2822) - # Replace LF with CRLF, encode using config.charset. + # Create a text/plain body using CRLF (see RFC2822) text = text.replace(u'\n', u'\r\n') text = text.encode(config.charset) - msg = MIMEText(text, 'plain', config.charset) + + # Create a message using config.charset and quoted printable + # encoding, which should be supported better by mail clients. + # TODO: check if its really works better for major mail clients + msg = Message() + charset = Charset(config.charset) + charset.header_encoding = QP + charset.body_encoding = QP + msg.set_charset(charset) + msg.set_payload(text) # Create message headers - msg['From'] = mail_from # Don't expose emails addreses of the other subscribers, instead we # use the same mail_from, e.g. "My Wiki <noreply@mywiki.org>" + msg['From'] = mail_from msg['To'] = mail_from msg['Date'] = formatdate() msg['Message-ID'] = make_msgid() - msg['Subject'] = Header(subject, config.charset) + msg['Subject'] = Header(subject, charset) + if cfg.mail_sendmail: # Set the BCC. This will be stripped later by sendmail. msg['BCC'] = ','.join(to)