簡體   English   中英

Python無法通過iRedMail發送電子郵件

[英]Python cannot send email via iRedMail

我已經在郵件服務器上安裝了iRedEmail。 現在它具有默認證書。 當我使用普通的電子郵件客戶端時,它要求我提供郵件服務器的TRUST證書,然后開始從郵件服務器接收/發送電子郵件

但是,如果我編寫自己的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程序便能夠發送電子郵件。 第一項服務與后綴策略有關

我只是在提示符下鍵入了以下命令

/etc/init.d/postfix-cluebringer restart

並在提示符下鍵入以下命令

/etc/init.d/amavis restart

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM