X-Git-Url: https://scm.cri.mines-paristech.fr/git/Plinn.git/blobdiff_plain/b74a186d8da401c587c4154c6008ff5bcf85e9cf..18ed8263755a35f5206a4a7205745f269b69bb06:/utils.py?ds=sidebyside diff --git a/utils.py b/utils.py index 7c5ceb7..8f6bd3d 100755 --- a/utils.py +++ b/utils.py @@ -261,6 +261,29 @@ def encodeQuopriEmail(name, email) : qpName = encodestring(name).replace('=\n', '') return '''"=?utf-8?q?%s?=" <%s>''' % (qpName, email) +def encodeMailHeader(content) : + s = encodestring(content).replace('=\n', '') + s = s.replace('_', '=5F') + s = s.replace(' ', '_') + + lines = [] + STEP = 50 + start = 0 + stop = STEP + part = s[start:stop] + lines.append(part) + + while len(part) == STEP: + start = start + STEP + stop = stop + STEP + part = s[start:stop] + lines.append(part) + + lines = [' =?utf-8?Q?%s?=' % part for part in lines] + s = '\n'.join(lines) + s = s.strip() + return s + def _sudo(func, userid=None) : """