0

I wrote a script to send an email using python. The script worked and the recipient received an email. However, I kept myself in CC and I didn't get an email and moreover, my outlook stopped working after that.

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()

1 Answers1

0

You're not sending the email to the CC list. You're adding the address in the head of the message, but not on the envelop.

x =s.sendmail(sender, [recipients, CC], msg.as_string())
Arthur Gouveia
  • 734
  • 4
  • 12