文章目錄
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、因爲
這裏給了個空值
連接的時候又給了個默認值,所以需要兩邊都設置下