Python email issues

pannis2013 at gmail.com pannis2013 at gmail.com
Tue Apr 26 01:37:23 EDT 2016


Hi,
I am trying send email through smtplib

import smtplib
import os
from libs import send_mail_status
send_mail_status('test', False, 'ABCD', os.getcwd())


libs.py has a function as below:
def send_status_mail(name, success, id, dir):
    #SERVER = "localhost"
    FROM = "localhost"
    TO = ["abc at nus.edu.sg"]
    SUBJECT = "test"
    body = "test"
    message = """\
    From: %s
    To: %s
    Subject: %s
    %s
    """ % (FROM, ", ".join(TO), SUBJECT, body)

But I receive an email as below: All the contents are in the email body:

From: localhost
    To: abc at nus.edu.sg
    Subject: test

    test

Why all the ocntents are written in the body where as email body should have just a string "test"
Kindly clarify. Thanks.



More information about the Python-list mailing list