niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Programming » python
Sendmail with many attach and recipients
Post new topic   Reply to topic Page 1 of 1 [1 Post] View previous topic :: View next topic
Author Message
Tim Williams
*nix forums beginner


Joined: 20 Feb 2005
Posts: 44

PostPosted: Thu Feb 03, 2005 4:22 pm    Post subject: Sendmail with many attach and recipients Reply with quote

<fernandestb@gmail.com> wrote in message
news:81b88e49.0502030850.490952c9@posting.google.com...
Here, my code of sendmail
If Somebody had a doubt please contact me?
fernandestb@gmail.com

[snip]

If you have multiple recipients, you need to modify

server.sendmail(msg['From'],toaddrs,msg.as_string())

to

failed = server.sendmail(msg['From'],toaddrs,msg.as_string())
# exception is only raised if ALL recips fail
# failed is a list of failed recips, or empty

You could also expand your smtplib exception handling
[not tested]

try:
server = smtplib.SMTP(servidor_smtp)
## Faz o envio do email.
try:
failed = server.sendmail(msg['From'],toaddrs,msg.as_string())
if failed:
do something
## Fecha a conexão com o servidor
except smtplib.SMTPRecipientsRefused, x : #all recips failed before
data sent = MSG failed
do something
except smtplip.SMTPDataError, x: # an error at the end of the
message body receipt = MSG Failed
do something
except smtplib.SMTPSenderRefused, x : # the sender was refused = MSG
failed
do something
except: #can't connect
do something
finally
server.quit()
except Exception, e:
arq=open(dir_log,'a')
print >> arq, "Falha no envio da mensagem de email, não foi

--

=================================
Tim Williams
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [1 Post] View previous topic :: View next topic
The time now is Fri Jan 09, 2009 12:13 am | All times are GMT
navigation Forum index » Programming » python
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Relay for specific recipients jvernice Postfix 0 Mon Sep 17, 2007 6:21 pm
No new posts Undisclosed Recipients ernstgv Postfix 0 Fri Aug 24, 2007 10:45 pm
No new posts Upgrade sendmail on 5.4-RELEASE-p7 brent.bolin@gmail.com FreeBSD 3 Fri Jul 21, 2006 2:00 am
No new posts Sendmail for Dummies? Rich Grise Slackware 14 Thu Jul 20, 2006 6:55 pm
No new posts HPSBUX02108 SSRT061133 rev.12 - HP-UX Running Sendmail, R... Security Alert HP-UX 0 Thu Jul 20, 2006 6:43 pm

Loans and Credit Cards | Internet Advertising | Secured Loans | Guitar Lesson | Credit Card Consolidation
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0986s ][ Queries: 16 (0.0318s) ][ GZIP on - Debug on ]