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
37
# -*- coding: utf-8 -*-
"""
Created on Wed Jan 31 13:14:14 2018
@author: hanye
"""
import smtplib, sys, email.utils, email_config_MSoutlook
mailserver=email_config_MSoutlook.smtpservername
#smtp_port=email_config_MSoutlook.smtp_port
mailserver='mail.csm.com.cn'
username=r'csm\hanye'
passwd='hy_csm_17'
From='ccr_maintainance@csm.com.cn'
To='hanye@csm.com.cn'
Tos=['hanye@csm.com.cn', 'yeahan@outlook.com']
Subj='Test maintainance warning'
Date=email.utils.formatdate()
text=('From: %s\nTo: %s\nDate: %s\nSubject: %s\n\n' % (From, To, Date, Subj))
print('Type message text, end with line=[Ctrl+d (Unix), Ctrl+z (Windows)]')
mail_body='This is a test.\nYou\'re receving this is because there might be something wrong with...'
print('Connecting...')
server=smtplib.SMTP(host=mailserver) # note here should NOT use SMTP_SSL
#server.starttls() # must NOT use this with csm mail service
#server.login(username, passwd) # must NOT use this to login server, no login needed for standard smtp
failed=server.sendmail(From, Tos, text+mail_body+email_config_MSoutlook.sender_signature)
server.quit()
if failed:
print('Failed recipients:', failed)
else:
print('No errors.')
print('Bye')