equal
deleted
inserted
replaced
8 from __future__ import absolute_import |
8 from __future__ import absolute_import |
9 |
9 |
10 import email |
10 import email |
11 import email.charset |
11 import email.charset |
12 import email.header |
12 import email.header |
|
13 import email.message |
13 import os |
14 import os |
14 import quopri |
|
15 import smtplib |
15 import smtplib |
16 import socket |
16 import socket |
17 import time |
17 import time |
18 |
18 |
19 from .i18n import _ |
19 from .i18n import _ |
214 |
214 |
215 def mimetextqp(body, subtype, charset): |
215 def mimetextqp(body, subtype, charset): |
216 '''Return MIME message. |
216 '''Return MIME message. |
217 Quoted-printable transfer encoding will be used if necessary. |
217 Quoted-printable transfer encoding will be used if necessary. |
218 ''' |
218 ''' |
219 enc = None |
219 cs = email.charset.Charset(charset) |
|
220 msg = email.message.Message() |
|
221 msg.set_type('text/' + subtype) |
|
222 |
220 for line in body.splitlines(): |
223 for line in body.splitlines(): |
221 if len(line) > 950: |
224 if len(line) > 950: |
222 body = quopri.encodestring(body) |
225 cs.body_encoding = email.charset.QP |
223 enc = "quoted-printable" |
|
224 break |
226 break |
225 |
227 |
226 msg = email.MIMEText.MIMEText(body, subtype, charset) |
228 msg.set_payload(body, cs) |
227 if enc: |
229 |
228 del msg['Content-Transfer-Encoding'] |
|
229 msg['Content-Transfer-Encoding'] = enc |
|
230 return msg |
230 return msg |
231 |
231 |
232 def _charsets(ui): |
232 def _charsets(ui): |
233 '''Obtains charsets to send mail parts not containing patches.''' |
233 '''Obtains charsets to send mail parts not containing patches.''' |
234 charsets = [cs.lower() for cs in ui.configlist('email', 'charsets')] |
234 charsets = [cs.lower() for cs in ui.configlist('email', 'charsets')] |