By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,345 Members | 1,783 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,345 IT Pros & Developers. It's quick & easy.

sendmail should throw an exception but does not

P: n/a
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.

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())

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

Regards, Clodoaldo Pinto Neto
Mar 25 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Clodoaldo napisał(a):
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.

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())

I guess that the error code returned by the destination mail server is
not is not forwarded to the client by my mail server.
Your local smtpd accepted the message for delivery, so everythong seems
to be OK. Following communication takes place between mail servers, so
your program has no possibility to know anything went wrong.

--
Jarek Zgoda
Skype: jzgoda | GTalk: zg***@jabber.aster.pl | voice: +48228430101

"We read Knuth so you don't have to." (Tim Peters)
Mar 25 '08 #2

P: n/a
On Tue, 25 Mar 2008 06:39:57 -0700 (PDT)
Clodoaldo <cl*************@gmail.comwrote:
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 <da***@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.
Mar 25 '08 #3

P: n/a
2008/3/25, D'Arcy J.M. Cain <da***@druid.net>:
On Tue, 25 Mar 2008 06:39:57 -0700 (PDT)
Clodoaldo <cl*************@gmail.comwrote:
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
Mar 25 '08 #4

P: n/a
Clodoaldo napisał(a):
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.
Good guess -- this is not possible until you (or your server) actually
send an email.

You can send a big "THANKYOU" to spammers, because their activity caused
nearly all mail server admins to disable VRFY command that is supposed
to do what you need.

--
Jarek Zgoda
Skype: jzgoda | GTalk: zg***@jabber.aster.pl | voice: +48228430101

"We read Knuth so you don't have to." (Tim Peters)
Mar 25 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.