cancel
Showing results for 
Search instead for 
Did you mean: 

Sending mail using webdynpro java

piyush_kumar6
Active Contributor
0 Kudos

*hi all,*

*i need to send mail using webdynpro java*

*i have used folloeing code*

String recepient ="myEmail_ID";

StringBuffer strMailBody;

String strSMTPIPAddress ="Myhostname";

Properties props;

Session session;

Provider p;

props = System.getProperties();

props.put("mail.smtp.host", strSMTPIPAddress);

session = Session.getDefaultInstance(props, null);

p = session.getProvider("smtp");

strMailBody = new StringBuffer();

strMailBody.append("My Messgae Body ...");

Message message = new MimeMessage(session);

message.setFrom(new InternetAddress("Email_Id"));

message.addRecipient(Message.RecipientType.TO, new InternetAddress(recepient));

message.setSubject("Employee Resignation Request");

message.setText(strMailBody.toString());

Transport.send(message);

*but i am getting following runtime error...*

javax.mail.SendFailedException: Sending failed; nested exception is: javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25; nested exception is: java.net.ConnectException: Connection refused: connect

So what should i need to change....to get the code working...

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Piyush,

Its appears that you haven't a service running a localhost port 25.

To certify about it, try to connect on localhost port 25 using telnet;

ie.: c:\telnet localhost 25

If it fail too, try to find the correct host and port that your SMTP is running.

Regards

Answers (1)

Answers (1)

Former Member
0 Kudos