• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java mail response code

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

I am having a mail sending class which sends the mail using SMTP server. Can you tell me is there any way i can receive some response code and message to confirm that the mail has been sent successfully by SMTP server?

Any pointers could be helpful.

thanks!!

abhi
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there a particular reason you're re-implementing SMTP instead of using the JavaMail API (which has readily accessible ways to get at response codes and such)?
 
abhi gupta
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ulf,

thanks for your quick response.

I am actually sending the mail using the java mail api to connect to smtp server and send it using the method:

msg.setSubject(subject);
msg.setContent(multipart);
transport.sendMessage(msg, msg.getAllRecipients());
transport.close();

Can you guide me if I can retrieve the response code and response message using the java api method. If there is pointer to code available for it, then it would be great!!

abhishek
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was actually misremembering this - response codes are not part of JavaMail, but they're part of the underlying Transport implementation. If you cast the Transport object to SMTPTransport you have the getLastServerResponse and getLastReturnCode methods available. Not quite the standard way, but probably safe to do since no other SMTP Transport implementations are shipped with JavaMail.
 
abhi gupta
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Ulf,

Thanks for your response!!

Do you have any idea if there is any way in which i can get the report (containing status) of all the mails sent in a period of time. i.e. for example: say in last 1 hour.

thanks!!

abhishek
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sure. Just save the response code/text of each mail being sent with its timestamp, and then you can report on it any way you want.
 
Mo-om! You're embarassing me! Can you just read a tiny ad like a normal person?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic