472,121 Members | 1,506 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,121 software developers and data experts.

Regarding Mail sending smtplib Module



Dear All,

I have doubt regarding mail sending smtplib
module. The below code is I used to send a mail.

##########################################
import email.Message
import email.Utils
import mimetypes
import os,string

fromAddr="pr******@enmail.com"
toAddr=
["pr**********@rediffmail.com","pr***@enmail.co m"]

mainMsg=email.Message.Message()
mainMsg["Date"]=email.Utils.formatdate(localtime=1)
mainMsg["Subject"]="en new contents"
mainMsg["From"]=fromAddr
mainMsg["To"]= string.join(toAddr,",")

## I am sending below message ## here

mainMsg.set_payload("Good to win win\n")

server = smtplib.SMTP('localhost')
server.set_debuglevel(1)
server.sendmail(fromAddr, toAddr, mainMsg.as_string())
server.quit()

######################

This is the output of above send mail program.

Here I want to avoid this line "Received: from unknown
(HELO prabahar.enmail.com) (59.92.13.47) by
mailserver with SMTP; 11 May 2005 10:09:11 -0000 " How
can I do this? . Why python give this line? . Mail
sending Module in php will not give this type line.
Here I have another doubt Php mail sending module give
MessageId automatically
but python doesn't set that. why?

output
*******

Return-Path: <pr******@enmail.com>
Delivered-To: pr**********@rediffmail.com
Received: (qmail 6865 invoked from network); 11 May
2005 10:09:11 -0000
Received: from unknown (HELO prabahar.enmail.com)
(59.92.13.47) by mailserver with SMTP; 11 May 2005
10:09:11 -0000

Received: (dqd 1118 invoked from network); 12 Apr 2005
06:38:59 -0000
Received: from unknown (HELO prabahar.enmail.com)
(127.0.0.1)
by prabahar.enmail.com with SMTP; 12 Apr 2005 06:38:59
-0000
Date: Tue, 12 Apr 2005 03:38:59 -0300
Subject: en new contents
From: pr******@enmail.com
To: pr**********@rediffmail.com,pr***@enmail.com

Good to win win
with regards
Prabahar

__________________________________________________ ______________________
Yahoo! India Matrimony: Find your life partner online
Go to: http://yahoo.shaadi.com/india-matrimony
Jul 19 '05 #1
1 3001
praba kar <pr*********@yahoo.co.in> wrote:
Here I want to avoid this line "Received: from unknown
(HELO prabahar.enmail.com) (59.92.13.47) by
mailserver with SMTP; 11 May 2005 10:09:11 -0000 " How
can I do this? . Why python give this line? . Mail
sending Module in php will not give this type line.
To quote http://docs.python.org/lib/SMTP-objects.html :
"The SMTP[sic] does not modify the message headers in any way."
The Received: header is being added by your SMTP server. Goodness
knows how PHP avoids it -- direct use of sendmail maybe?
Here I have another doubt Php mail sending module give
MessageId automatically
but python doesn't set that. why?


Because "The SMTP[sic] does not modify the message headers in
any way." Or, to look at it another way, there are obvious
advantages to having message ids created by the client app
rather than the library. (OTOH, the library author is more
likely to write better id-producing code than the average
client app author, but IMHO this is outweighed by the greater
utility of having the app do it and the consistency of not
having SMTP touch the headers.) If PHP mail adds a message id,
that would be consistent with it using sendmail rather than
talking directly to the SMTP server.

--
\S -- si***@chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/
___ | "Frankly I have no feelings towards penguins one way or the other"
\X/ | -- Arthur C. Clarke
her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by praba kar | last post: by
reply views Thread by praba kar | last post: by
1 post views Thread by praba kar | last post: by
9 posts views Thread by Leo Breebaart | last post: by
5 posts views Thread by morphex | last post: by
2 posts views Thread by ornto | last post: by
4 posts views Thread by peter.jones.rpi | last post: by
5 posts views Thread by sui | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.