cancel
Showing results for 
Search instead for 
Did you mean: 

Error: javax.mail.SendFailedException

Former Member
0 Kudos

Hi all,

I have a requirement to send a mail on click of a button. I have written a simple java code using java mail API. But while running the application i am getting

javax.mail.SendFailedException: Sending failed; nested exception is: javax.mail.SendFailedException: Invalid Addresses; nested exception is: javax.mail.SendFailedException: 550 5.7.1 Unable to relay for me@mydomain.com

If i run the java code as a standalone java application everything is fine. Only in webdynpro application i am getting the above mentioned error.

My question is do we have to configure any settings in the WAS. If so, can somebody give me a detailed answer how to do the configuration.

Thanks and Regards,

Rathna

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Rathna Ramamoorthy ,

You dont have to configure anything special in webdynpro.

Just check the Exchange Server Details like Host Name ( You will have some name or ip address).

javax.mail.SendFailedException: Invalid Addresses; nested exception is: javax.mail.SendFailedException: 550 5.7.1 Unable to relay for me@mydomain.com

That error is becase of wrong entry of Exchange Server Details.

Have you imported the required jar files? please check that also.

regards

Anil Dichpally

Former Member
0 Kudos

Thanks for all the answers.

Yes i have given the correct SMTP host and address.

I am running the java application in a different machine and not in the servers machine.

I have imported the required jar files also.

Former Member
0 Kudos

Hi Rathna,

You might have some kind AntiVirus on server, which might stop you from realying the mail. Please do check that.

Can you paste your code for sending mails here?

Regards,

Mausam

Former Member
0 Kudos

I stopped the Antivirus service and checked the application but it doesn't help.

Here is the code. But the code is working fine.

// Get system properties
Properties props = new Properties();
// Setup mail server
props.put("mail.pop3.host","myserver");
props.put("mail.pop3.auth","true");
						
Authentication auth = new Authentication("rathna.ramamoorthy@mydomain.com","abcd");
						
			Session session = Session.getInstance(props,auth);
			Store store = session.getStore("pop3");

			store.connect("myserver","rathna.ramamoorthy@mydomain.com","abcd");

			System.out.println("Connected");


			MimeMessage message =  new MimeMessage(session);
			message.setFrom(new InternetAddress("rathna.ramamoorthy@mydomain.com"));
			message.addRecipient(javax.mail.Message.RecipientType.TO, new InternetAddress("rathna.ramamoorthy@mydomain.com"));
			message.setSubject("Hello JavaMail Attachment");

			// create the message part
			MimeBodyPart messageBodyPart =  new MimeBodyPart();

			//fill message
			messageBodyPart.setText("Hi");
			Multipart multipart = new MimeMultipart();
			multipart.addBodyPart(messageBodyPart);

			// Part two is attachment
			messageBodyPart = new MimeBodyPart();
			String fileAttachment="D:\Message.txt";
			DataSource source =  new FileDataSource(fileAttachment);
			messageBodyPart.setDataHandler(new DataHandler(source));
			messageBodyPart.setFileName(fileAttachment);
			multipart.addBodyPart(messageBodyPart);

			// Put parts in message
			message.setContent(multipart);
						// Send the message
			javax.mail.Transport.send(message);
			
			System.out.println("Mail sent successfully");

			store.close();

Former Member
0 Kudos

Hi Rathna,

Try to initialize your Properties object like,

Properties props = System.getProperties(); It might get some properties from the framework its currently running.

and/or

Session object like,

Session session = Session.getDefaultInstance(props, auth);

Please check, if your none of the objects are NULL at the runtime.

Regards,

Mausam

Former Member
0 Kudos

As i told earlier the java code is working perfectly when i run it as a standalone java application.

Anyways i have changed the code tried as you have suggested. It doesnt help. Anyother clues..

Former Member
0 Kudos

Hi Rathna,

Please check if your security policies are allowing you to do this. Is your Mail Server reachable from WAS?

Not recommended but, can you try running your JAVA application from the WAS's machine?

Regards,

Mausam

former_member189631
Active Contributor
0 Kudos

Hi Rathna,

WAS setting is not required for mail sending module.

1)Please chk the SMTP Host is correct,

2)Please Chk the email address.

Regards,

Ramganesan K.