英文:
how to send an email from my regular outlook account using smtplib in python
问题
我正在尝试在Python中使用smtplib从我的常规Outlook(或其他电子邮件服务器)帐户发送电子邮件。但是,我只能找到有关从本地主机发送的帮助。有人可以帮我吗?
我已经尝试了许多在线建议,但似乎都不起作用。
英文:
Im trying to send an email from my regular outlook (or other email server) account in python using the smtplib.However I can only find help on sending from my localhost. Could anyone help me with this?
i have tried many suggestions online but none seem to work.
答案1
得分: 1
以下是您要翻译的代码部分:
import smtplib
username='yonihalberstadt@outlook.com'
password='******'
mailServer = smtplib.SMTP('smtp-mail.outlook.com', 587)
mailServer.login(username, password)
msg = """Hello!"""
mailServer.sendmail("yonihalberstadt@outlook.com",
"yonihalberstadt@outlook.com", msg)
希望这能帮助有相同问题的人!
ps: 如果有人可以解释以下代码行对我来说会很棒:
mailServer.ehlo()
mailServer.starttls()
mailServer.ehlo()
谢谢!
英文:
hey for anyone who this may help i managed to find a solution to the problem, although i dont fully understand the code.
import smtplib
username='yonihalberstadt@outlook.com'
password='******'
mailServer = smtplib.SMTP('smtp-mail.outlook.com', 587)
mailServer.login(username, password)
msg = """
Hello!"""
mailServer.sendmail("yonihalberstadt@outlook.com",
"yonihalberstadt@outlook.com", msg)
hope this helps anyone with the same problem!
ps: if anyone could explain the followings lines of code to me would be great:
mailServer.ehlo()
mailServer.starttls()
mailServer.ehlo()
thx!
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论