cancel
Showing results for 
Search instead for 
Did you mean: 

Issue in sending mail from webdynpro application

Former Member
0 Kudos

Error :

javax.mail.SendFailedException: Sending failed; nested exception is: javax.mail.MessagingException: Unknown SMTP host: mail.yochanatech.com ; nested exception is: java.net.UnknownHostException: mail.yochanatech.com

In visual administrator

SMTP hostname : mail.yochantech.com

this my code ;



	String host ="mail.yochanatech.com "; // Specify the host
//	   Get the From Address
//	String from = wdContext.currentContextElement().getFromAddress();
	String from ="arjun@yochanatech.com";
//	   Get the To Address
//	String to = wdContext.currentContextElement().getToAddress();
	String to="arjun@yochanatech.com";
//	   Initialize Session
	Properties props = System.getProperties();
	props.put("mail.smtp.host", host);
	
	Session session = Session.getDefaultInstance(props, null);
//	   Create new MimeMessage
	MimeMessage message = new MimeMessage(session);
	IWDMessageManager messageMgr = wdControllerAPI.getComponent().getMessageManager();
	try {
 // Set the From Address
		message.setFrom(new InternetAddress(from));
//		   Set the To Address
		message.addRecipient(Message.RecipientType.TO,
		new InternetAddress(to));
//		   Set the Subject
		message.setSubject("Test Mail");
//		   Set the Text
//		message.setText(wdContext.currentContextElement().getTextMessage());
		message.setText("test mail trigered");
//		   Send message

               
		Transport.send(message);
			
		messageMgr.reportSuccess("Mail Sent Successfully");
		} catch (AddressException e) {
		messageMgr.reportException(e.toString(),false);
		} catch (MessagingException e) {
		messageMgr.reportException(e.toString(),false);
		}

when i debug the code

Transport.send(message);

it is not exceuting

Thxs

ARJUN.G

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

have you tried with the IP of the respective host.

Regards

Ayyapparaj

Former Member
0 Kudos

hi,

tried with the ip address and it worked fine...

thanx..

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Arjun,

Check the host name again (the spelling)

according to u in visual admin it : SMTP hostname : mail.yochantech.com

In ur code its : mail.yochanatech.com

regards

Sumit

Former Member
0 Kudos

Hi,

Is SMTP Port configured in the server system.

Regards,

Sudhir