Is it possible to know a message sending fail in a java program.

Posted in Help the coder! on May 3, 2009 at 12:53 IST (over 4 years ago). Subscribe to this post Bookmark and Share Email
Showing comments 1 to 6 of total 6 on page 1 of 1
Post reply
« Previous1Next »

kavitha_k
Rank: 110

Is there any way to resend the mail through a java program,If a mail sending fails?
I am using EmailMDB(Transport.send(msg)) to send mails.

Please let me know if anything more to be conveyed.

Thanks in advance.
kavitha

Posted by kavitha_k on Sunday, May 3, 2009, 12:53 pm
  • Currently 0.00/5

0 votes

Thank this userFlag this comment

flasum4u
Rank: 134
Posted by flasum4u on Monday, May 4, 2009, 12:10 am
  • Currently 0.00/5

0 votes

Thank this userFlag this comment

kavitha_k
Rank: 110

Hey thanks flasum4u for the reply....:)

I am able to send mails using JavaMail...but my problem is, I would like to resend the mails if the delivery fails due to various reasons, like improper Email id's or it could be any other problem.

I just want to identify the message delivery failures and resend the message either to the recipients again or to the admin as a email.How could i do so?

Posted by kavitha_k on Monday, May 4, 2009, 2:00 pm
  • Currently 0.00/5

0 votes

Thank this userFlag this comment

sureshcc
Rank: 10

Hey Kavitha,

I assume you're talking about tracking a mail after it's been sent. Correct me if I'm wrong here.

The way SMTP is implemented, this is not quite possible. Well, at least not without a considerable effort. If your program is talking to an SMTP relay (well most probably your SMTP server host), and the relay contacts the end-user SMTP host in real time while keeping you waiting, it has a chance of getting to know whether the delivery was successful.

However, this is not the case in the real life scenario. What the SMTP server you talk to does is, it accepts your mail for delivery and queues it. Later, when the polling iteration arrives, it sends the mail out to the next relay, or in some cases, directly to the final SMTP host. So, most probably, when you send an email, your SMTP server does not know whether it's going to be a success or not and hence you won't be able to decide it that time.

Now if you are really serious about this and you want it to be done, the only way I could think of now is like the following:

  • Set the reply-to and return-path e-mail fields to one of your own POP3 email box address while you send the email. Also, set a unique hash (that matches with your stored database value) in one of the mail headers.
  • Periodically poll the POP3 inbox for an incoming mail using POP3 protocol.
  • If a mail has returned that contains a daemon delivery failure text as well as the matching hash you sent, you have a bounced mail.


It's pretty complicated and I wouldn't recommend doing it until in the real necessity. Let me know more information about what you are trying to build here and I can be of further assistance to you.

Thankful users: kavitha_k
Posted by sureshcc on Monday, May 4, 2009, 10:16 pm
  • Currently 0.00/5

0 votes

Thank this userFlag this comment

kavitha_k
Rank: 110
Thanks for the solution.....yes, i was trying to track a mail after it's been sent.Cos i dont want to lose any message being delivered to the user.

I have another doubt ....Is it good to use the concept of acknowledgment for this problem?If so how?.....cos i dont know how to do so.
Posted by kavitha_k on Thursday, May 7, 2009, 5:14 pm
  • Currently 0.00/5

0 votes

Thank this userFlag this comment

tsanand129
Rank: 23
Hey
Not sure whats the exact application you are working on.
But I used JavaMail for sending emails from my application.
But later I found out about JAMES
JAMES is Java Apache Mail Enterprise Server (james.apache.org/ )
Its an Open Source Project and provides lots of functionalities and
error handling capabilities (something which you are looking for).

Hope this Helps!!!

PS. Setting up the environment and Writing Email Client is very easy,
with source code freely available.
Posted by tsanand129 on Sunday, August 16, 2009, 2:52 pm
  • Currently 0.00/5

0 votes

Thank this userFlag this comment
Pages: « Previous1Next »

Post your comment (No registration required)

  Add my comment  

TechieDesi Community

Not signed in (Sign-in or Register)
Be a true TechieDesi!
Top 10 Users
Spread the word
Invite your friends
Fan stuff
Help us improve
Need Help
FAQ's
Search tips
Found a bug? Report!
Feeds and letters
Subscribe via RSS
Archives
Subscribe to newsletter
Unsubscribe e-mail
Miscellaneous
Privacy policy
Visit rootnerve
About us
About us
Support the development
Official Blog
Advertise with us
Careers
Copyright (c) 2008, TechieDesi.com. All rights reserved | About us | Do-Not-Disturb registry | Powered by rootnerve | Page rendered in 0.019 seconds