forked from aqzt/kjyw
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env python | ||
#coding:utf-8 | ||
from email.mime.text import MIMEText | ||
from email.header import Header | ||
import smtplib | ||
|
||
sender='[email protected]' | ||
sender_pass='xxxxxxxxxxxxxx' | ||
host='smtp.qq.com' | ||
recivers=['[email protected]'] | ||
def mail(): | ||
message=MIMEText('python 邮件发送111','plain','utf-8') | ||
message['From']='{}'.format(sender) | ||
message['To']=','.join(recivers) | ||
message['Subject']='邮件测试222' | ||
|
||
try: | ||
smtpobj=smtplib.SMTP_SSL(host,465)#启用ssl,端口为465 | ||
|
||
smtpobj.login(sender,sender_pass) | ||
|
||
smtpobj.sendmail(sender,recivers,message.as_string()) | ||
print('sucess') | ||
smtpobj.quit() | ||
except: | ||
print('error') | ||
|
||
mail() |