[Tutor] problem with rejected mail smtplib

Rob Sinclar lunixinclar at orange.fr
Sun Jul 30 15:16:31 CEST 2006


> Hello there,
> i have a customer list, each with a number of email address that we
> send notifications to via text message.
> the problem is, there are a number of providers ( just two ) that
> reject our messages.
>
> What error do you get with the rejection?
>
>
> the script goes a little something like this :
>
> Address = 'going at somewhere.net <mailto:going at somewhere.net>'
> From = 'me at myhost.net <mailto:me at myhost.net>'
> message = 'From: me at myhost.net\r\nTo: %s\r\nSubject: %s\r\n\r\n%s' %
> (Address,'alert',message)
> server.sendmail(From, Address, message)
>
> most of the time it goes thru ok. but only some providers have a
> problem. However, those same providers get messages if i send them
> thru Evolution.
>
> any ideas of what to check out?

I'd look at sendmail() exceptions, described in the smtplib docs.

try:
  m.sendmail(...)
except SMTPRecipientsRefused:
    print "All recipients were refused...."
except SMTPHeloError:
    print "The server didn't reply properly to the ...."
except SMTPSenderRefused:
    print "The server didn't accept the..."
except SMTPDataError:
   print "The server replied with an ..."


More information about the Tutor mailing list