Handle non-ASCII characters in body and subject
Change-Id: I522482c9d8cca1493206988694c8d497bc9d32d5
This commit is contained in:
parent
72d281a0cd
commit
a62a7ec2ae
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
import csv
|
import csv
|
||||||
import email.utils
|
import email.utils
|
||||||
|
import email.mime.text
|
||||||
import settings
|
import settings
|
||||||
import smtplib
|
import smtplib
|
||||||
import sys
|
import sys
|
||||||
@ -27,7 +28,7 @@ from string import Template
|
|||||||
class ATC(object):
|
class ATC(object):
|
||||||
def __init__(self, row):
|
def __init__(self, row):
|
||||||
self.lpid = row[0]
|
self.lpid = row[0]
|
||||||
self.name = row[1]
|
self.name = unicode(row[1], 'utf8')
|
||||||
self.emails = row[2:]
|
self.emails = row[2:]
|
||||||
|
|
||||||
|
|
||||||
@ -67,22 +68,17 @@ if __name__ == '__main__':
|
|||||||
content = template.substitute(name=committer.name,
|
content = template.substitute(name=committer.name,
|
||||||
code=code,
|
code=code,
|
||||||
signature=settings.EMAIL_SIGNATURE)
|
signature=settings.EMAIL_SIGNATURE)
|
||||||
msg = (
|
|
||||||
"From: %s\r\n"
|
|
||||||
"To: %s\r\n"
|
|
||||||
"Date: %s\r\n"
|
|
||||||
"Message-ID: %s\r\n"
|
|
||||||
"Subject: %s\r\n"
|
|
||||||
"%s"
|
|
||||||
% (
|
|
||||||
settings.EMAIL_FROM,
|
|
||||||
','.join(committer.emails),
|
|
||||||
email.utils.formatdate(),
|
|
||||||
email.utils.make_msgid(),
|
|
||||||
settings.EMAIL_SUBJECT,
|
|
||||||
content))
|
|
||||||
|
|
||||||
session.sendmail(settings.EMAIL_FROM, committer.emails, msg)
|
msg = email.mime.text.MIMEText(content, 'plain',
|
||||||
|
'utf8')
|
||||||
|
msg["From"] = settings.EMAIL_FROM
|
||||||
|
msg["To"] = ','.join(committer.emails)
|
||||||
|
msg["Date"] = email.utils.formatdate()
|
||||||
|
msg["Message-ID"] = email.utils.make_msgid()
|
||||||
|
msg["Subject"] = settings.EMAIL_SUBJECT
|
||||||
|
|
||||||
|
session.sendmail(settings.EMAIL_FROM, committer.emails,
|
||||||
|
msg.as_string())
|
||||||
print "%s,ATC,%s" % (code, committer.name)
|
print "%s,ATC,%s" % (code, committer.name)
|
||||||
session.quit()
|
session.quit()
|
||||||
time.sleep(settings.EMAIL_PAUSE)
|
time.sleep(settings.EMAIL_PAUSE)
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# coding=utf8
|
||||||
# Settings for the passcode-sending application
|
# Settings for the passcode-sending application
|
||||||
#
|
#
|
||||||
# Copyright 2013 Thierry Carrez <thierry@openstack.org>
|
# Copyright 2013 Thierry Carrez <thierry@openstack.org>
|
||||||
@ -15,9 +16,9 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
EMAIL_SUBJECT = "Your registration code for OpenStack Summit in Portland"
|
EMAIL_SUBJECT = u"Your registration code for OpenStack Summit in Portland"
|
||||||
|
|
||||||
EMAIL_TEMPLATE = """
|
EMAIL_TEMPLATE = u"""
|
||||||
Hello $name,
|
Hello $name,
|
||||||
|
|
||||||
As you may already know, we'll be having our next OpenStack Summit
|
As you may already know, we'll be having our next OpenStack Summit
|
||||||
@ -42,7 +43,7 @@ $signature
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
EMAIL_FROM = "thierry@openstack.org"
|
EMAIL_FROM = "thierry@openstack.org"
|
||||||
EMAIL_SIGNATURE = "Thierry Carrez\nOpenStack Foundation"
|
EMAIL_SIGNATURE = u"Thierry Carrez\nOpenStack Foundation"
|
||||||
EMAIL_HOST = "secure.emailsrvr.com"
|
EMAIL_HOST = "secure.emailsrvr.com"
|
||||||
EMAIL_PORT = 465
|
EMAIL_PORT = 465
|
||||||
EMAIL_USER = "thierry.carrez@openstack.org"
|
EMAIL_USER = "thierry.carrez@openstack.org"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user