JavaMail does not throw exceptions??

Discussion in 'Java' started by moo moo, Oct 22, 2003.

  1. moo moo

    moo moo Guest

    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.
    moo moo, Oct 22, 2003
    #1
    1. Advertising

  2. > 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
    Michiel Konstapel, Oct 22, 2003
    #2
    1. Advertising

  3. moo moo

    Roedy Green Guest

    On Wed, 22 Oct 2003 22:03:45 +0200, "Michiel Konstapel"
    <> wrote or quoted :

    >> 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.


    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


    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Oct 22, 2003
    #3
  4. moo moo wrote:

    > 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
    John C. Bollinger, Oct 22, 2003
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kerri
    Replies:
    2
    Views:
    12,981
    Kevin Spencer
    Oct 27, 2003
  2. Replies:
    15
    Views:
    7,461
    Roedy Green
    Sep 8, 2005
  3. Replies:
    4
    Views:
    1,563
  4. Robert
    Replies:
    22
    Views:
    647
    Kevin McMurtrie
    Jun 12, 2008
  5. Emanuele D'Arrigo

    To throw or to throw not?

    Emanuele D'Arrigo, Nov 14, 2008, in forum: Python
    Replies:
    6
    Views:
    300
    Emanuele D'Arrigo
    Nov 15, 2008
Loading...

Share This Page