473,545 Members | 2,095 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

email and smtplib modules

Hi,

I'm writing a small script that generates email and I've noticed that:

1) one should add the 'To' and 'CC' headers to the email message
2) one needs to specify the recipients in the smtplib sendmail() method

Can someone explain how these are related?

Thanks,
Mark

Jul 18 '05 #1
3 1828
"ma************ @gmail.com" <ma************ @gmail.com> writes:
Hi,

I'm writing a small script that generates email and I've noticed that:

1) one should add the 'To' and 'CC' headers to the email message
2) one needs to specify the recipients in the smtplib sendmail() method

Can someone explain how these are related?


Sure.

It's all to do with smtp. With smtp mail, as with paper mail, there is
an "envelope" that has addresses on it that the mail system uses to
deliver messages, and the "letter", that has addresses in it that are
displayed to the end user.

The To: and Cc: headers in the message itself are in the letter. The
end user sees those. smtp servers ignore them.

The recipients passed to the smtplib sendmail() method go on the
envelope. The smtp server will deliver to those addresses, and they
won't be shown to end users.

This design makes many things possible. Most used these days is spam
delivered to one address while apparently to another.

<mike
--
Mike Meyer <mw*@mired.or g> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Jul 18 '05 #2
# mw*@mired.org / 2005-04-09 16:42:04 -0500:
"ma************ @gmail.com" <ma************ @gmail.com> writes:
Hi,

I'm writing a small script that generates email and I've noticed that:

1) one should add the 'To' and 'CC' headers to the email message
2) one needs to specify the recipients in the smtplib sendmail() method

Can someone explain how these are related?

...
This design makes many things possible. Most used these days is spam
delivered to one address while apparently to another.


What about mailing lists? Quoting from your message as it arrived
here:

Return-Path: py************* *************** *************** *************** ***@python.org
X-Original-To: ne************* *************** **@sigpipe.cz
From: Mike Meyer <mw*@mired.or g>
To: py*********@pyt hon.org

For the OP:

Return-Path: header contains the envelope sender (SMTP MAIL command)
X-Original-To: is the envelope recipient (SMTP RCPT command)

So, despite the email claiming to be sent from Mike to the list,
it's actually from the list to me.

Please take Mike's note about spam with two grains of salt, the
distinction between headers and envelope is vital to the SMTP
protocol and many services built around it.

--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991
Jul 18 '05 #3
Hi Mike,

Thanks for the quick tutorial :) Quite helpful.

Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
2002
by: sean | last post by:
Is there a good module for sending out email? For a website that I am working on, I am writing a program that finds out which presenters have not yet confirmed their scheduled date and sends them an email to confirm. Does python have any modules for use with mail programs like sendmail, or should I just run everything with os.system and...
6
5392
by: bojanraic | last post by:
Hi! I recently started playing with Python CGI, and I was happy that my basic input-name--print-hello-name CGI form example worked, so I thought I should advance to somew\hat more complicated scripts. I'm trying to write a basic Python email CGI script to send email through HTML email form. I've seen a lot of examples out there, but...
5
1699
by: Xah Lee | last post by:
# -*- coding: utf-8 -*- # Python # Suppose you want to spam your friend, and you have lots of # friends. The solution is to write a program to do it. After a gander # at python docs, one easily found the module for the job. # see http://python.org/doc/2.3.4/lib/SMTP-example.html # the code is a bit long with the command line, but the key...
5
12633
by: morphex | last post by:
Hi, I have an email that's in the utf-8 encoding, and I'm getting this error message when I try to send it using smtplib: * Module smtplib, line 688, in sendmail * Module smtplib, line 485, in data * Module smtplib, line 312, in send * Module socket, line 1, in sendall
1
2960
by: Grzegorz ¦lusarek | last post by:
Hi all. I sending email using standard python modules smtplib, email, coding email in utf but subject of message is not coded properly. In subject i use my national characters (polish) and after send i get XX in place these characters. Here is the code Message = email.message_from_string(pMessage) Message.set_charset('utf-8') Message =...
0
1736
by: gillespie.amanda | last post by:
How do I add a Sender name to the emails sent by the following script: def createhtmlmail (html, text, subject): """Create a mime-message that will render HTML in popular MUAs, text in better ones""" import MimeWriter import mimetools import cStringIO out = cStringIO.StringIO() # output buffer for our message
3
2504
by: Erik Johnson | last post by:
THE GOAL: I need to send an email with a simple ASCII text body and an attached HTML file. I have scripts that send basic emails via the smtplib module that don't have any attachements and that seems to work fine. I first looked at the mimetools modules but it says it is depreceated since 2.3, so I started trying to use the email module. ...
2
2633
by: oyster | last post by:
I find that the existing email moudle is some hard for me to understand, especially the part of how to set the CC, BCC and attach the files. Is there any more easy one like this p-code? import easyemail smtpserver=easyemail.server('something') smtpserver.login('usr@gmail.com', pwd) newletter=smtpsever.letter(smtpserver) newletter.sendto=...
5
5041
by: Jsnova864 | last post by:
I want to write a program similiar to kgb spy for my flash drive. So when I lose it, it will email me with keylogger event and give me an idea of where it is or who took it. I dont know anything about emialing so i dont know how to write a pogram that does it xD. I picked this up from somewhere. apologizer for not remebering where i got...
0
7464
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7656
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7805
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7413
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7751
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
4943
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3440
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1012
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
700
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.