python - 使用 python 脚本从 CPanel 电子邮件发送电子邮件
问题描述
我正在尝试从 Cpanel 电子邮件发送电子邮件,但我尝试的所有操作都面临同样的错误 [Errno 11001] getaddrinfo failed
这是我的代码,我在 Google 域中尝试过,它工作正常,但 Cpanel 不工作?有没有办法使用 python 发送电子邮件?
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email import encoders
from email.mime.image import MIMEImage
email_user = 'something@Mydomain.com'
email_password = 'password'
email_send = "someemail@gmail.com"
subject = "Testing 2"
msg = MIMEMultipart()
msg['From'] = email_user
msg['To'] = email_send
msg['Subject'] = subject
h = str("Holder")
c = str("course")
t = str("trainer")
html = """\
<html>
<head></head>
<body>
<p >Hello {h} This {t} we need your conf. on {c} </p>
</body>
</html>
""".format(h=h , c=c , t=t)
msg.attach(MIMEText(html,'html'))
server = smtplib.SMTP('smtp.gmail.com',587)
server.starttls()
server.login(email_user,email_password)
server.sendmail(email_user,email_send,msg.as_string())
server.quit()
所以你怎么看?
解决方案
是的,你必须改变server = smtplib.SMTP('yourDomain.com',25)
推荐阅读
- linq - 使用 Group by 时无法翻译 LINQ 表达式
- error-handling - 如何处理 rust 中的自定义字符串错误?
- spring - 如何使用 ConfigDataEnvironmentPostProcessor 和 spring.profiles.group?
- python - 访问字典中的嵌套列表
- amp-html - 无法确定放大器关键帧
- python - Uvicorn/FastAPI 作为带有 cx_Freeze 的 Windows 服务,无法停止服务
- c++ - C ++算法的复杂性?
- javascript - ionic vue ion-back-button 没有按预期工作
- bash - bash - 无法将 git clone 的整个输出保存到变量中
- asp.net-mvc - 我无法在 ASP.NET MVC 中将 POST 请求从视图发送到控制器