sendmail should throw an exception but does not

Clodoaldo clodoaldo.pinto at gmail.com
Tue Mar 25 10:58:30 EDT 2008


2008/3/25, D'Arcy J.M. Cain <darcy at druid.net>:
> 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.

Thanks for the objective answer. I'm now reconnected to reality. The
problem i'm trying to solve is to check if an email address is valid.

That email address is used to register in a site. I'm already doing
the confirmation email path. The confirmation email prevents someone
to register with a forged email but also prevents those who simple
don't know exactly what their email is. Yes the email must be typed
twice but still people get the email wrong just because they don't
know for sure what it is. I can see it clearly when they mistype the
correct domain.

It happens that atracting those people is expensive and i can't afford
to loose them. Thats why i would like to check the email at
registration time. Also those who try to register with a forged email
would learn that the email must be confirmed and could then issue a
correct email.

I guess it is not possible or is too complex because i never saw it done.

Regards, Clodoaldo Pinto Neto



More information about the Python-list mailing list