【问题标题】:Python cannot send email via iRedMailPython 无法通过 iRedMail 发送电子邮件
【发布时间】:2016-03-13 17:44:06
【问题描述】:

我已经在我的邮件服务器上安装了 iRedEmail。现在它有默认证书。当我使用普通的电子邮件客户端时,它会要求我信任邮件服务器的证书,然后开始从邮件服务器接收/发送电子邮件

但是如果我编写自己的 python 程序来发送电子邮件,那么我不知道如何像电子邮件客户端那样做同样的事情。目前python给出错误“服务器配置问题”

SMTPserver = 'smtp.xxxx.com
SMTPport = 587
sender =     'info@xxx.com'
destination = ['testgmailid@gmail.com']

USERNAME = "info@xxxx.com"
PASSWORD = "1234"

text_subtype = 'plain'

subject="Sent from Python"

import sys
import os
import re

from smtplib import SMTP       
from email.MIMEText import MIMEText

try:
    msg = MIMEText(content, text_subtype)
    msg['Subject']=       subject
    msg['From']   = sender 

    conn = SMTP(SMTPserver,SMTPport)
    conn.set_debuglevel(True)
    conn.ehlo()
    conn.starttls()
    conn.login(USERNAME, PASSWORD)
    try:
        conn.sendmail(sender, destination, msg.as_string())
    finally:
        conn.close()

except Exception, exc:
    sys.exit( "mail failed; %s" % str(exc) ) # give a error message

【问题讨论】:

  • 没有您的代码,我们无法真正帮助您...
  • 抱歉,添加了编码。但这不是代码问题。似乎我正在运行python代码的机器,我应该添加证书或以某种方式将邮件服务器的证书传递给python。我不知道

标签: python starttls iredmail


【解决方案1】:

所以问题是有两个服务没有运行

以下是这两种服务。启动这两个服务的那一刻,python 程序就能够发送电子邮件。第一个服务与postfix的策略有关

我刚刚在提示符下输入了以下命令

/etc/init.d/postfix-cluebringer restart

并在提示符下键入以下命令

/etc/init.d/amavis restart

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-02-04
    • 2011-03-30
    • 2013-02-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-26
    • 2014-05-28
    相关资源
    最近更新 更多