Python 發郵件報錯 server_hostname cannot be an empty string or start with a leading dot.

Python 發郵件報錯 server_hostname cannot be an empty string or start with a leading dot.


1、使用環境,報錯內容

python 3.8

ValueError: server_hostname cannot be an empty string or start with a leading dot.

2、代碼

server = smtplib.SMTP_SSL()
server.connect(mail_config.smtp_server, mail_config.smtp_port)

3、需要改爲

server = smtplib.SMTP_SSL(mail_config.smtp_server)
server.connect(mail_config.smtp_server, mail_config.smtp_port)

4、因爲

這裏給了個空值
在這裏插入圖片描述

連接的時候又給了個默認值,所以需要兩邊都設置下

在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章