on 03-08-2007 5:47 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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();
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.