如何解决如何将电子邮件从计算机发送到gmail?
我想构建smtp服务器,这是我的代码
import smtplib
import email.utils
from email.mime.text import MIMEText
# Create the message
msg = MIMEText('This is the body of the message.')
msg['To'] = email.utils.formataddr(('Recipient','mygmail@gmail.com'))
msg['From'] = email.utils.formataddr(('mygmail','myemail@email.com'))
msg['Subject'] = 'Simple test message'
server = smtplib.SMTP('my_ip',25)
server.set_debuglevel(True) # show communication with the server
try:
server.sendmail('myemail@email.com',['mygmail@gmail.com'],msg.as_string())
finally:
server.quit()
当我也是听众的时候效果很好 这是我的python2监听代码
import smtpd
import asyncore
class CustomSMTPServer(smtpd.SMTPServer):
def process_message(self,peer,mailfrom,rcpttos,data):
print 'Receiving message from:',peer
print 'Message addressed from:',mailfrom
print 'Message addressed to :',rcpttos
print 'Message length :',len(data)
print '\n\n',data
print '\n__________________________________________________________________________________\n'
return
server = CustomSMTPServer(('192.168.200.14',25),None)
asyncore.loop()
但是如果出现此错误,我是否将此代码发送到我的gmail帐户
send: 'ehlo [127.0.1.1]\r\n'
reply: b'250-smtp.gmail.com at your service,[79.181.102.40]\r\n'
reply: b'250-SIZE 35882577\r\n'
reply: b'250-8BITMIME\r\n'
reply: b'250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH\r\n'
reply: b'250-ENHANCEDSTATUSCODES\r\n'
reply: b'250-PIPELINING\r\n'
reply: b'250-CHUNKING\r\n'
reply: b'250 SMTPUTF8\r\n'
reply: retcode (250); Msg: b'smtp.gmail.com at your service,[79.181.102.40]\nSIZE 35882577\n8BITMIME\nAUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH\nENHANCEDSTATUSCODES\nPIPELINING\nCHUNKING\nSMTPUTF8'
send: 'mail FROM:<mikigabay@walla.com> size=241\r\n'
reply: b'530-5.7.0 Authentication Required. Learn more at\r\n'
reply: b'530 5.7.0 https://support.google.com/mail/?p=WantAuthError a83sm3060044wmh.48 - gsmtp\r\n'
reply: retcode (530); Msg: b'5.7.0 Authentication Required. Learn more at\n5.7.0 https://support.google.com/mail/?p=WantAuthError a83sm3060044wmh.48 - gsmtp'
send: 'rset\r\n'
reply: b'250 2.1.5 Flushed a83sm3060044wmh.48 - gsmtp\r\n'
reply: retcode (250); Msg: b'2.1.5 Flushed a83sm3060044wmh.48 - gsmtp'
send: 'quit\r\n'
reply: b'221 2.0.0 closing connection a83sm3060044wmh.48 - gsmtp\r\n'
reply: retcode (221); Msg: b'2.0.0 closing connection a83sm3060044wmh.48 - gsmtp'
Traceback (most recent call last):
File "send.py",line 14,in <module>
server.sendmail('mikigabay@walla.com',['eyyalgabay@gmail.com'],msg.as_string())
File "/usr/lib/python3.8/smtplib.py",line 871,in sendmail
raise SMTPSenderRefused(code,resp,from_addr)
smtplib.SMTPSenderRefused: (530,b'5.7.0 Authentication Required. Learn more at\n5.7.0 https://support.google.com/mail/?p=WantAuthError a83sm3060044wmh.48 - gsmtp','mikigabay@walla.com')
我尝试通过nc收听以了解gmail如何发送电子邮件,但看不到 我尝试将SSL与端口465一起使用,但出现相同的错误
我如何从我的smtp服务器向gmail发送电子邮件?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。