Python:Hotmail发邮件

发布于 2021-11-07 00:39:43 字数 895 浏览 844 评论 1

import poplib

M = poplib.POP3_SSL('pop3.live.com', 995) #Connect to hotmail pop3 server

try: 

    M.user(raw_input("username: ")) #Get the username from the standar input
    M.pass_(raw_input("password: ")) #Get the password from the standar input
except:

    print "username or password incorrect"
else:

    print "Successful login"

import smtplib

msg = "warning"

msg['From'] = "capstons2011jm4@hotmail.com"

msg['To'] = "yuxun88@hotmail.com"

msg['Subject'] = "hello"

s = smtplib.SMTP("smtp.live.com",25)

s.sendmail("capstones2011jm4@hotmail.com", "yuxun88@hotmail.com", msg.as_string())

s.quit()

使用Python登陆Hotmail没问题,发送还是有些麻烦。

TypeError: 'str' object does not support item assignment  
This keep coming up. I have no idea why.
谁晓得?指导一二。

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无声静候 2021-11-09 03:56:03

 

import poplib

M = poplib.POP3_SSL('pop3.live.com', 995) #Connect to hotmail pop3 server

try: 

    M.user(raw_input("username: ")) #Get the username from the standar input
    M.pass_(raw_input("password: ")) #Get the password from the standar input
except:

    print "username or password incorrect"
else:

    print "Successful login"

import smtplib
from email.mime.text import MIMEText

#msg = "warning"
#建议你看下帮助文档,还有就是既然使用hotmail 获取邮件建议使用imap协议
msg = MIMEText("warning")

msg['From'] = "capstons2011jm4@hotmail.com"

msg['To'] = "yuxun88@hotmail.com"

msg['Subject'] = "hello"

s = smtplib.SMTP("smtp.live.com",25)

s.sendmail("capstones2011jm4@hotmail.com", "yuxun88@hotmail.com", msg.as_string())

s.quit()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文