JavaMail does not throw exceptions??

M

moo moo

Hi,

Im using JavaMail. When sending emails from a servlet, if there is
something wrong wih the email address I do not get an exception,
instead the email gets returned as undeliverable.

Does this sound right /plausible? Off the top of my head it seems
plausible if the emails are queued in some way and sent later .. which
makes sense, but I dont know about this stuff. But I was hoping that
on attempting to send the email an exception would be thrown if the
address did not exist and then I could take steps programatically to
mark the address as being invalid etc.

Presently Im having to manually mark emails as invalid which is not
practical and does not scale up!

thanks,
m.
 
M

Michiel Konstapel

Im using JavaMail. When sending emails from a servlet, if there is
something wrong wih the email address I do not get an exception,
instead the email gets returned as undeliverable.

Does this sound right /plausible? Off the top of my head it seems
plausible if the emails are queued in some way and sent later .. which
makes sense, but I dont know about this stuff. But I was hoping that
on attempting to send the email an exception would be thrown if the
address did not exist and then I could take steps programatically to
mark the address as being invalid etc.

Presently Im having to manually mark emails as invalid which is not
practical and does not scale up!

That's the way email works. It's not delivered immediately. Usually, the
clients sends it to a "local" SMTP server, which forwards it to the target
domain's SMTP server. This then decides what to do with it: deliver,
forward, bounce, ignore, etc. Once JavaMail has delivered it to the
smtp.host server, it's out of its hands.
Michiel
 
R

Roedy Green

When I wrote my bulk emailer I used a multi-prong approach to the
problem of bad addresses.

First, when they are keyed into the Abundance database they get a
validity check.

Next when they go to the emailer they get a complex regex check that
comes up with a number from 0 to 10 on how likely the address is good.

Then I use DNS to look up the mailserver and see if the domain exists.
I keep a database of previous probe history so I don't panic if the
mailserver disappears for an hour or two. I also have an exception
list of domains such as aol.com and hotmail.com that don't play by the
MX rules.

Then the mailserver may reject my emails, but in practice it never
does.

Then finally the emails may bounce back. Then some phones up the
person to get the new email addreses for the database.

see http://mindprod.com/products.html#BULK
 
J

John C. Bollinger

moo said:
Hi,

Im using JavaMail. When sending emails from a servlet, if there is
something wrong wih the email address I do not get an exception,
instead the email gets returned as undeliverable.

Does this sound right /plausible?

It certainly sounds plausible. It is consistent with the API docs for
javax.mail.Transport. If the Transport does not recognize a problem
with the e-mail address then you will not get an exception, but instead
some other form of failure notification, such as a bounce message.
Off the top of my head it seems
plausible if the emails are queued in some way and sent later .. which
makes sense, but I dont know about this stuff. But I was hoping that
on attempting to send the email an exception would be thrown if the
address did not exist and then I could take steps programatically to
mark the address as being invalid etc.

E-mail is generally an asynchronous affair. A message usually must be
handed off from one transport agent to another along a chain of several
agents between sender and receiver. If another transport agent accepts
the message from your JavaMail application then your application will
not receive an exception.
Presently Im having to manually mark emails as invalid which is not
practical and does not scale up!

So write a second application with which to process bounce messages.
You might even be able to get it to receive them automatically, but even
if you have to dump them to a file and feed them to it you're better off
than if you maintain the list manually.


John Bollinger
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top