Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc79818e

Browse files
author
FlyPython
authored
Update sendemail.py
1 parentfb56f85 commitc79818e

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

‎sendemail.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,13 @@
2525

2626
#登录并发送邮件
2727
try:
28-
smtpObj=smtplib.SMTP()
29-
#连接到服务器
30-
smtpObj.connect(mail_host,25)
31-
#登录到服务器
32-
smtpObj.login(mail_user,mail_pass)
28+
smtpObj=smtplib.SMTP_SSL(mail_host,465)# 启用SSL发信, 端口一般是465
29+
smtpObj.login(mail_user,mail_pass)# 登录验证
3330
#发送
3431
smtpObj.sendmail(
3532
sender,receivers,message.as_string())
3633
#退出
3734
smtpObj.quit()
3835
print('success')
3936
exceptsmtplib.SMTPExceptionase:
40-
print('error',e)#打印错误
37+
print('error',e)#打印错误

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp