-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsend_mail.py
36 lines (29 loc) · 1.14 KB
/
send_mail.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from exchangelib import Account, Message, CalendarItem, Credentials, \
Configuration, EWSDateTime, EWSTimeZone, Attendee, Mailbox, DELEGATE
from exchangelib.protocol import BaseProtocol, NoVerifyHTTPAdapter
BaseProtocol.HTTP_ADAPTER_CLS = NoVerifyHTTPAdapter
creds = Credentials(
username="ex.gasf.com\\Administrator",
password="tech121login*")
config = Configuration(server='ex.gasf.com', credentials=creds)
a = Account(primary_smtp_address="[email protected]",
autodiscover=False,
config = config,
access_type=DELEGATE)
# You can also send emails. If you don't want a local copy:
m = Message(
account=a,
subject='Daily motivation',
body='All bodies are beautiful',
to_recipients=[
Mailbox(email_address='[email protected]'),
Mailbox(email_address='[email protected]'),
],
cc_recipients=['[email protected]', '[email protected]'], # Simple strings work, too
bcc_recipients=[
Mailbox(email_address='[email protected]'),
], # Or a mix of both
)
if m.send():
print ('mail send successfully')