File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes How to send a mail to different email id Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to send a mail to different email id" Watch "How to send a mail to different email id" New topic
Author

How to send a mail to different email id

Sanjeev Janardhanan
Greenhorn

Joined: Sep 16, 2010
Posts: 4
I have caught up with an issue.

I have tried the below listed code to send mail. The issue is

eg: 1) from :abc@sam.com To : acd@sam.com , it works fine.
2) from :abc@sam.com To : acd@don.com, it leads to an issue.

issue:

javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay for sanjeev.janardhanan@gmail.com

at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1607)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:887)
at javax.mail.Transport.send0(Transport.java:191)
at javax.mail.Transport.send(Transport.java:142)
at com.servion.FileUpload.doPost(FileUpload.java:235)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay for sanjeev.janardhanan@gmail.com

at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1458)


Code:

Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Welcome to JavaRanch Sanjeev

There is a JavaMail FAQ in oracle
http://www.oracle.com/technetwork/java/faq-135477.html

by the way: Please use code tag while posting your code.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38033
    
  22
Seetharaman Venkatasamy wrote: . . . Please use code tag while posting your code.
Since he's new, I'll add them and he can see how much better the post looks
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Campbell Ritchie wrote:Since he's new, I'll add them and he can see how much better the post looks

Great!
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
These days you will almost always have to use authentication (info about which is in the FAQ mentioned above). Just about the only exceptions are if you either a) use a mail server you have set up yourself without authentication, or b) send mail within a company network - that's case 1 you mention.
Sanjeev Janardhanan
Greenhorn

Joined: Sep 16, 2010
Posts: 4
Thank you very much for the good reply and correction made.
 
 
subject: How to send a mail to different email id
 
Similar Threads
how to send mail using gmail server
Sending Email in java through MS Exchange Server
What should be the value of 'host' when I send an e-mail?
com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay