Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #107639 > unrolled thread

Python email issues

Started bypannis2013@gmail.com
First post2016-04-25 22:37 -0700
Last post2016-04-26 05:41 -0500
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  Python email issues pannis2013@gmail.com - 2016-04-25 22:37 -0700
    Re: Python email issues Tim Chase <python.list@tim.thechases.com> - 2016-04-26 05:41 -0500

#107639 — Python email issues

Frompannis2013@gmail.com
Date2016-04-25 22:37 -0700
SubjectPython email issues
Message-ID<f4153463-3201-4673-a214-d34d24210409@googlegroups.com>
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@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@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.

[toc] | [next] | [standalone]


#107648

FromTim Chase <python.list@tim.thechases.com>
Date2016-04-26 05:41 -0500
Message-ID<mailman.103.1461667504.32212.python-list@python.org>
In reply to#107639
On 2016-04-25 22:37, pannis2013@gmail.com wrote:
> I am trying send email through smtplib
>     body = "test"
>     message = """\
>     From: %s
>     To: %s
>     Subject: %s
>     %s
>     """ % (FROM, ", ".join(TO), SUBJECT, body)

Doesn't the email RFC require a blank line between the headers and
the body of the message?

I'd start by using Python's built-in tools for creating message
bodies to make sure that the message is properly composed.

-tkc


[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web