我写了一个脚本来使用python发送电子邮件。该脚本有效,收件人收到了一封电子邮件。但是,我一直在CC,我没有收到电子邮件,而且我的展望在此之后停止了工作。
import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
def success_email():
sender = 'abhishek_talwar@xyz.com'
recipients = 'GANA_PANGO@xyz.com'
CC = 'abhishek_talwar@xyz.com'
subject = "Load Balance Request Completed"
msg = MIMEMultipart('alternative')
msg['Subject'] = subject
msg['From'] = sender
msg['To'] = recipients
msg['CC'] = CC
# Create the body of the message (a plain-text and an HTML version).
text = 'Hi this is a test mail'
# Record the MIME types of both parts - text/plain and text/html.
part1 = MIMEText(text.encode('utf-8'), 'html')
# Attach parts into message container.
msg.attach(part1)
s = smtplib.SMTP('mail1.xyz.com')
x =s.sendmail(sender, recipients, msg.as_string())
print x
action = 'Success email sent for'
print action
success_email()
答案 0 :(得分:0)
您没有将电子邮件发送到CC列表。你要在邮件的头部添加地址,但不要在信封上添加。
x =s.sendmail(sender, [recipients, CC], msg.as_string())