我正在尝试使用Python 3.7中带有smtplib
的公司电子邮件地址发送电子邮件。
这是我的代码:
import smtplib
from email.mime.text import MIMEText
from_addr='myEmail@corporate.com'
to_addr='myEmail@corporate.com'
server = smtplib.SMTP('corporateServer', 'port')
server.starttls()
msg = MIMEText('send my python', 'plain', 'utf-8')
server.sendmail(from_addr, to_addr, msg.as_string())
server.quit()
错误:
Traceback (most recent call last): File "script.py", line 51, in
<module>
server = smtplib.SMTP(smtpServer, 25) File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/smtplib.py",
line 251, in __init__
(code, msg) = self.connect(host, port) File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/smtplib.py",
line 336, in connect
self.sock = self._get_socket(host, port, self.timeout) File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/smtplib.py",
line 307, in _get_socket
self.source_address) File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socket.py", line 727, in create_connection
raise err File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socket.py", line 716, in create_connection
sock.connect(sa) TimeoutError: [Errno 60] Operation timed out