48
def make_mime_message(message_id, text, headers=None, hidden=False,
48
def make_mime_message(message_id, body='body', headers=None, hidden=False,
49
49
attachment_type=None):
50
50
message = MIMEMultipart()
51
message.attach(MIMEText(text))
52
message['Message-Id'] = message_id
53
if headers is not None:
54
for k, v in headers.items():
51
message.attach(MIMEText(body))
56
52
if attachment_type is not None:
57
53
attachment = Message()
58
54
attachment.set_payload('attactment data.')
59
55
attachment['Content-Type'] = attachment_type
60
attachment['Content-Disposition'] = (
61
'attachment; filename="file.ext"')
56
attachment['Content-Disposition'] = 'attachment; filename="file.ext"'
62
57
message.attach(attachment)
64
'message_id': message_id,
65
'headers': dict(message.items()),
66
'body': message.get_payload(),
58
return make_message(message_id, message.get_payload(), headers, hidden)
71
61
def threaded_messages(messages):