sendmail should throw an exception but does not

D'Arcy J.M. Cain darcy at druid.net
Tue Mar 25 10:21:13 EDT 2008


On Tue, 25 Mar 2008 06:39:57 -0700 (PDT)
Clodoaldo <clodoaldo.pinto at gmail.com> wrote:
> I need to know if an email was refused for whatever reason, it makes
> no difference.
> 
> The email is sent to an email address that does not exist in a foreign
> domain. I can see in the postfix log that the email was sent and
> bounced with the error code 550.

That's the sendmail daemon, not your program.

> The problem is that sendmail should throw an exception but it does
> not. And the returned dictionary is empty as if the email was
> accepted.
> 
> d = smtpserver.sendmail(sender, recipient, m.as_string())

What this does is connect to your sendmail server and submit the email
for sending.  The server accepts the email and queues it up as asked.
No error here.

> I guess that the error code returned by the destination mail server is
> not is not forwarded to the client by my mail server.

It can't.  By the time it finds out that there is a problem you have
already closed the connection to the sendmail server.

To do what you want you have to connect to the remote server yourself.
This is a more complicated operation and there are still problems.
First of all, your ISP may not allow you to connect to remote mail
servers.  Second, some [broken] mail servers will accept your email and
only check and bounce after you have disconnected.

I'm not sure what you are trying to do but you may want to consider
using an Error-to: header that points to an email robot and manage
bounces asynchronously.

-- 
D'Arcy J.M. Cain <darcy at druid.net>         |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.



More information about the Python-list mailing list