MCPcopy Create free account
hub / github.com/ActiveState/code / compose_email

Function compose_email

recipes/Python/578807_Sending_Email/recipe-578807.py:59–87  ·  view source on GitHub ↗
(addresses, subject, body, files)

Source from the content-addressed store, hash-verified

57# 1 - html
58# files is list of strings
59def compose_email(addresses, subject, body, files):
60
61 # addresses
62 to_address = addresses[0];
63 cc_address = addresses[1];
64 bcc_address = addresses[2];
65
66 # create a message
67 msg = create_msg(to_address, cc_address=cc_address , subject=subject);
68
69 # add text
70 for text in body:
71 attach_text(msg, text[0], text[1]);
72
73 # add files
74 if (files != ''):
75 file_list = files.split(',');
76 for afile in file_list:
77 attach_file(msg, afile);
78
79 # send message
80 send_email(server, username, password, msg, 0);
81
82 # check for bcc
83 if (bcc_address != ''):
84 msg['Bcc'] = bcc_address;
85 send_email(server, username, password, msg, 1);
86
87 print 'email sent'
88
89# attach text
90# attaches a plain text or html text to a message

Callers 1

recipe-578807.pyFile · 0.85

Calls 5

attach_textFunction · 0.85
attach_fileFunction · 0.85
create_msgFunction · 0.70
send_emailFunction · 0.70
splitMethod · 0.45

Tested by

no test coverage detected