Question about smtplib, and mail servers in general.

Tim Williams (gmail) tdwdotnet at gmail.com
Tue Sep 20 13:33:26 CEST 2005


On 20/09/05, Chris Dewin <notrealaddress at all.com> wrote:
> 
> s = smtplib.SMTP("server")
> s.sendmail(fromaddress, 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("server")
>for addr in toaddresses:
>      s.sendmail(fromaddress,[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 :)



More information about the Python-list mailing list