473,657 Members | 2,476 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Question about smtplib, and mail servers in general.

Hi. I've been thinking about using smtplib to run a mailing list from my website.

s = smtplib.SMTP("s erver")
s.sendmail(from address, toaddresess, msg)

I know that in this instance, the toaddresses variable can be a variable
of type list.

Suppose the list contains well over 100 emails. Would that create some
sort of drain on the mail server? Would I be better off doing it in some
other way?

--
www.wintergreen.in

Sep 20 '05 #1
12 2810
On 20/09/05, Chris Dewin <no************ @all.com> wrote:

s = smtplib.SMTP("s erver")
s.sendmail(from address, toaddresess, msg)

I know that in this instance, the toaddresses variable can be a variable
of type list.

Suppose the list contains well over 100 emails. Would that create some
sort of drain on the mail server? Would I be better off doing it in some
other way?
Suppose the list contains well over 100 emails
You mean the list of recipients (toaddresses) ?

The 2 lines of example code send a *single* email to "server" with
len(toaddresses ) recipients. The server will then split the email
into smaller (or individual) email groups to send (depending on the
server in use and the mechanisms it uses to relay the email)

You could send a single email for each recipient to "server"
s = smtplib.SMTP("s erver")
for addr in toaddresses:
s.sendmail(from address,[addr], msg)

# in later revisions, [addr] can be a list, or a string of one address

but that would create much more load on your machine AND server

HTH :)
Sep 20 '05 #2
Chris Dewin wrote:
Hi. I've been thinking about using smtplib to run a mailing list from my website.

s = smtplib.SMTP("s erver")
s.sendmail(from address, toaddresess, msg)

I know that in this instance, the toaddresses variable can be a variable
of type list.

Suppose the list contains well over 100 emails. Would that create some
sort of drain on the mail server? Would I be better off doing it in some
other way?


Not really an answer to your question, but it's probably considered bad
style to publish the email addresses of the recipients via the address
list. Use a neutral To-address (best: the mailing list address) and add
the recipients via bcc: headers.

You might also want to look at mailman
http://www.gnu.org/software/mailman/, which is a complete mailing list
solution written in Python.

Daniel
Sep 20 '05 #3
On 20/09/05, Daniel Dittmar <da************ @sap.corp> wrote:
Chris Dewin wrote:
Hi. I've been thinking about using smtplib to run a mailing list from my website.

s = smtplib.SMTP("s erver")
s.sendmail(from address, toaddresess, msg)


Not really an answer to your question, but it's probably considered bad
style to publish the email addresses of the recipients via the address
list. Use a neutral To-address (best: the mailing list address) and add
the recipients via bcc: headers.


For clarity

The toaddreses don't show in the email, they are the envelope TO:
addreses. The addresses in the email's TO: Headers are shown to the
recipient and these are the ones that should be "disguised" as best
practice for mailing lists.

The email module's replace_header( 'to', 'new-text) will do the job for you.
Sep 20 '05 #4
Daniel Dittmar wrote:
Chris Dewin wrote:
Hi. I've been thinking about using smtplib to run a mailing list from
my website.

s = smtplib.SMTP("s erver")
s.sendmail(from address, toaddresess, msg)

I know that in this instance, the toaddresses variable can be a variable
of type list.

Suppose the list contains well over 100 emails. Would that create some
sort of drain on the mail server? Would I be better off doing it in some
other way?


Not really an answer to your question, but it's probably considered bad
style to publish the email addresses of the recipients via the address
list. Use a neutral To-address (best: the mailing list address) and add
the recipients via bcc: headers.


Not only not an answer, but also not a valid point in this case. The
list of recipients used in the sendmail() call (which become RCPT TO:
commands in SMTP) do *not* show up in the received emails. Only those
items explicitly listed in the headers, such as the To: header, will
appear. In fact, you could easily make a Bcc: header which actually
lists everyone and it would probably not even be stripped by most mail
programs (though I haven't tried that). Your confusion is caused by not
distinguishing between mail client programs and a lower level utility
such as smtplib, which doesn't even look at the To: addresses in the header.

-Peter
Sep 20 '05 #5
Chris Dewin wrote:
Hi. I've been thinking about using smtplib to run a mailing list from my website.

s = smtplib.SMTP("s erver")
s.sendmail(from address, toaddresess, msg)

I know that in this instance, the toaddresses variable can be a variable
of type list.

Suppose the list contains well over 100 emails. Would that create some
sort of drain on the mail server? Would I be better off doing it in some
other way?


Definitely consider a proper mailing list program like Mailman, as
Daniel suggested.

In any case, unless the mail server will allow "relaying", which most
don't these days (to prevent spamming), then it won't work the way you
are hoping unless *all* the 100 addresses are local ones, to be
delivered to users on the server you are sending the mail to.

If the addresses are scattered all over the planet, and the server
allows relaying, then it's intended for exactly this sort of use (other
than if it's spam ;-) ), and no, you won't be putting a "drain" on the
server.

-Peter
Sep 20 '05 #6
Peter Hansen wrote:
Chris Dewin wrote:
Hi. I've been thinking about using smtplib to run a mailing list from my website.

s = smtplib.SMTP("s erver")
s.sendmail(fr omaddress, toaddresess, msg)

I know that in this instance, the toaddresses variable can be a variable
of type list.

Suppose the list contains well over 100 emails. Would that create some
sort of drain on the mail server? Would I be better off doing it in some
other way?

Definitely consider a proper mailing list program like Mailman, as
Daniel suggested.

In any case, unless the mail server will allow "relaying", which most
don't these days (to prevent spamming), then it won't work the way you
are hoping unless *all* the 100 addresses are local ones, to be
delivered to users on the server you are sending the mail to.

If the addresses are scattered all over the planet, and the server
allows relaying, then it's intended for exactly this sort of use (other
than if it's spam ;-) ), and no, you won't be putting a "drain" on the
server.

-Peter

To add one final note, if the "fromaddres s" belongs to a domain that's
properly handled by the SMTP server then you aren't relaying (since you
are a legitimate domain user) so the mails should go through.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.pycon.org

Sep 20 '05 #7
>>>>> Steve Holden <st***@holdenwe b.com> (SH) wrote:
SH> To add one final note, if the "fromaddres s" belongs to a domain that's
SH> properly handled by the SMTP server then you aren't relaying (since you are
SH> a legitimate domain user) so the mails should go through.


And most smtp servers that I know also pass mail from any from-address to
any to-address if the IP number of he client machine belongs to a trusted
range (usually the range that belongs to the ISP). So I can send both my
private mail and my work mail from both my home ISP's smtp server and my
work's smtp server (but only if I am at the proper location).
--
Piet van Oostrum <pi**@cs.uu.n l>
URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C 4]
Private email: pi**@vanoostrum .org
Sep 20 '05 #8
Peter Hansen <pe***@engcorp. com> writes:
Daniel Dittmar wrote:
Chris Dewin wrote:
Hi. I've been thinking about using smtplib to run a mailing list
from my website.

s = smtplib.SMTP("s erver")
s.sendmail(from address, toaddresess, msg)

I know that in this instance, the toaddresses variable can be a variable
of type list.

Suppose the list contains well over 100 emails. Would that create some
sort of drain on the mail server? Would I be better off doing it in some
other way?

Not really an answer to your question, but it's probably considered
bad style to publish the email addresses of the recipients via the
address list. Use a neutral To-address (best: the mailing list
address) and add the recipients via bcc: headers.


Not only not an answer, but also not a valid point in this case. The
list of recipients used in the sendmail() call (which become RCPT TO:
commands in SMTP) do *not* show up in the received emails.


Not quite. The email address each letter is actually delivered to
generally shows up in one or more Received: headers in the received
email. Some MTAs will add a header (qmail adds Delivered-To:, for
instance) with that same address in it when they deliver the mail
locally. Most MUAs don't display those, but they are there. There may
be an MTA that will pass a single message along to multiple recipients
after adding all of them to one or more headers. I don't know that
such exist - but I wouldn't trust that they don't.

Since you shouldn't trust email to be secure in any case, this isn't a
big deal. Note that using Bcc: doesn't help with this issue - the
addresses a message is delivered to *have* to be in the envelope. Bcc
puts them there and not in the headers.

<mike
--
Mike Meyer <mw*@mired.or g> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Sep 20 '05 #9
Steve Holden wrote:
Peter Hansen wrote:
In any case, unless the mail server will allow "relaying", which most
don't these days (to prevent spamming), then it won't work the way you
are hoping unless *all* the 100 addresses are local ones, to be
delivered to users on the server you are sending the mail to.

If the addresses are scattered all over the planet, and the server
allows relaying, then it's intended for exactly this sort of use
(other than if it's spam ;-) ), and no, you won't be putting a "drain"
on the server.


To add one final note, if the "fromaddres s" belongs to a domain that's
properly handled by the SMTP server then you aren't relaying (since you
are a legitimate domain user) so the mails should go through.


I think that statement might not be widely valid any more, Steve. In my
experience, lately, many if not most servers pay no attention to the
"MAIL FROM" address but instead allow relaying only from *IP addresses*
on the "internal" network (e.g. those served by an ISP, for example),
regardless of how the sender is identified. On a Linux box with Qmail,
for example, one would have an /etc/tcp.smtp file which specifies for
which subnets relaying is allowed, and all others are disallowed
regardless of the claimed MAIL FROM address.

It's kind of a shame, really, that you can no longer trust either the
recipient *or* the sender addresses when using basic SMTP. Damn spammers.

-Peter
Sep 21 '05 #10

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

Similar topics

2
4853
by: Garry Hodgson | last post by:
how do i use smtplib to send mail to someone with "cc" to someone else? if i just include the "to" addressees in the call to smtplib.sendmail(), and put the others in the "Cc" header fields, only the "To" recipients get the mail, thought the mail headers look right. but if i also add the "Cc" folks to the list of recipients in the call to smtplib.sendmail(), it arrives at their mailer with their address listed on both the "To" and "Cc"...
0
1731
by: Frank Zheng | last post by:
I wrote some code to test "smtplib", but i met a problem when i call the "login(user,pass)" of the "SMTP" object. here are the codes: >>> s = smtplib.SMTP() >>> s.set_debuglevel(1) >>> s.connect('smtp.263.net') connect: ('smtp.263.net', 25) connect: ('smtp.263.net', 25) reply: '220 Welcome to coremail System(With Anti-Spam) 2.1 for
3
1833
by: mark.greenbank | last post by:
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,
6
10013
by: Matthias Kluwe | last post by:
Hi! After getting a @gmail.com address, I recognized I had to use TLS in my python scripts using smtplib in order to get mail to the smtp.gmail.com server. Things work well so far, apart from an unexpected error. Here's my sample code: import smtplib
3
4385
by: Van_Gogh | last post by:
Hi, I am learning how to use the smtplib module, but am having some very early problems, maybe because I don't understand it. So, am I correct that by following the example in the Python: >>> import smtplib >>> server = smtplib.SMTP('localhost') >>> server.sendmail('soothsayer@example.org', 'jcaesar@example.org', """To: jcaesar@example.org
0
1864
by: Roger | last post by:
I am having a problem sending email through smtp.gmail.com using smtplib. Everything works and the mail is sent and received, except quit. The following shows the problem (without bothering to login or do the sendmail): I have not had this problem with other mail servers (but only tried two). A solution for gmail seems to be to replace the server.quit() with server.close(). The difference between the two commands is quit() sends a...
2
1927
by: ornto | last post by:
Hi, I'm trying to create an application which checks a dynamic web site and on certain events sends an email to me. My problem though is with the email task. By now I made this simple test code: #prova invio email smtpserver = smtplib.SMTP(mailserver) messaggio= "Messaggio di prova" print mail print messaggio
1
2385
by: Hunter | last post by:
I am writing a script that needs to send some emails. And I've used smtplib in the past and it is pretty easy. But I thought, gee it would be easier if I could just call it as a function, passing the from, to, subject, and message text. So I wrote it up as a function and it sort of works, but I get a weird error. When it runs it inserts a "\t" tab character before each item during the send portion (which I can see when I turn on...
5
1739
by: yoma | last post by:
hi guys! I want to use python send an email to acceptor. $B!!(BAnd i hope to receive the message that the acceptor has read my email. So how to realize that get the message?
0
8842
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8617
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7353
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2743
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1733
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.