Send email notification

E

Ernesto

Is there a special module for mail ?

I'd like to send an email [to 'n' unique email addresses] from a python
script.

Thanks !
 
R

rtilley

Ernesto said:
Is there a special module for mail ?

I'd like to send an email [to 'n' unique email addresses] from a python
script.

from email.MIMEText import MIMEText
import email.Utils
import smtplib

# 'users' is a list of email addys.
for u in users:
try:
print "Sending email to ... ", u
f = "FROM_NAME<FROM_EMAIL_ADDY@YOUR_DOMAIN.com>"
t = u

msg = MIMEText("""MESSAGE BODY OF EMAIL""")

msg["Subject"] = "MESSAGE SUBJECT"
msg["Message-id"] = email.Utils.make_msgid()
msg["From"] = f
msg["To"] = t

h = "YOUR.SMTP.SERVER"
s = smtplib.SMTP(h)
s.sendmail(f, t, msg.as_string())
s.quit()
except Exception, e:
print e
 
S

Steve Holden

Ernesto said:
I guess that was jerk-off version of:

"smtplib"

Thanks a lot.
Well, it gave you the information you wanted, right? (Except that it
might have mentioned the "email" package, which would help you
formulating the messages as well.

But that which doesn't kill us makes us stronger, and at least you
aren't dead :)

Hang around here long and you'll see a bunch of people waiting on
replies to questions Google could have given them far quicker. If we
weren't paid thousands of dollars a week to answer questions on this
list we'd probably get snarky more often.

regards
Steve
 
D

Dennis Lee Bieber

Hang around here long and you'll see a bunch of people waiting on
replies to questions Google could have given them far quicker. If we
weren't paid thousands of dollars a week to answer questions on this
list we'd probably get snarky more often.
What! Why didn't anyone tell me where to submit my timecard?
--
 
G

Grant Edwards

Hang around here long and you'll see a bunch of people waiting
on replies to questions Google could have given them far
quicker. If we weren't paid thousands of dollars a week to
answer questions on this list we'd probably get snarky more
often.

That reminds me: I haven't seen last weeks check yet. I trust
it will arrive soon...
 
C

Christos Georgiou

If we
weren't paid thousands of dollars a week to answer questions on this
list we'd probably get snarky more often.

Steve, please, don't make me look like a liar in front of the children!
 
P

Peter Hansen

Dennis said:
What! Why didn't anyone tell me where to submit my timecard?

It's by the *byte*, Dennis. How did you think Alex managed all that
time off real work to write a book on Python (like anyone buys those)?

;-)

-Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top