此代码"假设"发送电子邮件.
import smtplib
#SERVER = "localhost"
FROM = 'myEmail@email.com'
TO = ["toEmail@email.com"] # must be a list
SUBJECT = "Hello!"
TEXT = "This message was sent with Python's smtplib."
# Prepare actual message
message = """\
From: %s
To: %s
Subject: %s
%s
""" % (FROM, ", ".join(TO), SUBJECT, TEXT)
# Send the mail
server = smtplib.SMTP('myserver')
server.sendmail(FROM, TO, message)
server.quit()
Run Code Online (Sandbox Code Playgroud)
我收到此错误消息.
Traceback (most recent call last):
File "C:\Users\myCpu\Documents\myFiles\python\test wy.py", line 1, in <module>
import smtplib
File "C:\Python27\lib\smtplib.py", line 46, …Run Code Online (Sandbox Code Playgroud)