473,386 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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 1818
"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.org> 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.org>
To: py*********@python.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
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...
6
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...
5
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...
5
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,...
1
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...
0
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...
3
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...
2
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...
5
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...

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.