我有以下代码
import smtplib
from email.mime.text import MIMEText
smtpserver = 'smtp.gmail.com'
AUTHREQUIRED = 1 # if you need to use SMTP AUTH set to 1
smtpuser = 'admin@myhost.com' # for SMTP AUTH, set SMTP username here
smtppass = '123456' # for SMTP AUTH, set SMTP password here
RECIPIENTS = ['online8@gmail.com']
SENDER = 'admin@myhost.com'
msg = MIMEText('dsdsdsdsds\n')
msg['Subject'] = 'The contents of iii'
msg['From'] = 'admin@myhost.com'
msg['To'] = ''online8@gmail.com''
mailServer = smtplib.SMTP('smtp.gmail.com',587)
mailServer.ehlo()
mailServer.starttls()
mailServer.ehlo()
mailServer.login(smtpuser, smtppass)
mailServer.sendmail(smtpuser,RECIPIENTS,msg.as_string())
mailServer.close()
这段代码在我的桌面电脑上运行正常,但出现了以下错误:
smtplib.SMTPAuthenticationError: (535, '5.7.1 Username and Password not accepted. Learn more at\n5.7.1 http://mail.google.com/support/bin/answer.py?answer=14257 21sm4713429agd.11')
在我的Linux服务器上。
不确定出了什么问题,我是否需要在我的Linux服务器上打开一些端口?