File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other JSE/JEE APIs and the fly likes Exception in sending a mail Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Exception in sending a mail" Watch "Exception in sending a mail" New topic

Exception in sending a mail

Komal Amaresh
Ranch Hand

Joined: Oct 06, 2008
Posts: 67

I' am trying to send a mail and there is a messaging exception being raised at the Transport class.
I' am using the following code to send a mail.

There is a messaging ezception thrown as it reaches the line where I' am passing the message. The message ia html content sent as an array of bytes used in a different application.
The exception thrown is as follows:

A messaging excepttion is thrown at Transport.send(message).
Can you help me resolve the issue. I need to resolve this immediately.

Thanks and regards,
Komal Amaresh
Ranch Hand

Joined: Oct 06, 2008
Posts: 67

I' am not able to connect to the smtp server. I' am running the MailSender class as a standalone application in which I have included the code above. Now I have tried including transport.connect() where it is throwing an exception.
The exception in the standalone code is as follows:

javax.mail.MessagingException: Exception reading response;
nested exception is: Connection reset
at com.sun.mail.smtp.SMTPTransport.readServerResponse(
at com.sun.mail.smtp.SMTPTransport.openServer(
at com.sun.mail.smtp.SMTPTransport.protocolConnect(
at javax.mail.Service.connect(
at javax.mail.Service.connect(
at javax.mail.Service.connect(
at com.sun.mail.smtp.SMTPTransport.connect(
at com.tanla.lms.MailSender.sendMail(
at com.tanla.lms.MailSender.main(

The exception is thrown in the line transport.connect()
Should I use SMTPtransport instead of Transport? I have o fix this.
I had never worked on javax.mail earlier. Now I dont have a clue whats creating the problem.
I would be glad if you can help identify where the problem is and rectify my code.
Thanks in advance.


I agree. Here's the link:
subject: Exception in sending a mail
It's not a secret anymore!