在py執行smtp.qq.com的動作時
執行日誌返回
File "/www/wwwroot/pythonFlask/app.py", line 47, in submit_form snedStatus = send_qq_mail( File "/www/wwwroot/pythonFlask/app.py", line 79, in send_qq_mail smtp.connect(smtpserver) File "/www/server/pyporject_evn/pythonFlask_venv/lib/python3.9/smtplib.py", line 341, in connect self.sock = self._get_socket(host, port, self.timeout) File "/www/server/pyporject_evn/pythonFlask_venv/lib/python3.9/smtplib.py", line 312, in _get_socket return socket.create_connection((host, port), timeout, File "/www/server/pyporject_evn/pythonFlask_venv/lib/python3.9/socket.py", line 843, in create_connection raise err File "/www/server/pyporject_evn/pythonFlask_venv/lib/python3.9/socket.py", line 831, in create_connection sock.connect(sa) OSError: [Errno 101] Network is unreachabl
確認你在程式碼中使用的 SMTP 伺服器地址和埠是正確的。對於 QQ 郵箱,通常使用 smtp.qq.com
,埠 465(SSL)或 587(TLS)。