aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes Please Help me to remove this SMTP Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Please Help me to remove this SMTP Error " Watch "Please Help me to remove this SMTP Error " New topic

Please Help me to remove this SMTP Error

Talha-bin -Shakir
Ranch Hand

Joined: Jan 26, 2006
Posts: 32
Here is My Code.

<%@page import="java.util.*"%>
<%@page import="javax.mail.*"%>
<%@page import="javax.mail.internet.*"%>

Properties props = new Properties();

props.put("","true", "localhost");

Session s = Session.getInstance(props, null);

MimeMessage message = new MimeMessage(s);
InternetAddress from = new InternetAddress("admin@luckyascot");

InternetAddress toAddress = new InternetAddress("");

message.addRecipient(Message.RecipientType.TO, toAddress);

message.setSubject("This is a Private and Confidential Mail From");

message.setText("Here is Your Password");


<p align="center">
A Message has been sent. <br>
Check your inbox.

<p align="center">
<a href="sendmail.jsp">Click here to send another!</a>

when i run i get error:

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

Please Help me to solve this Problem
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

This doesn't look like a programming error.
It looks like the SMTP server is rejecting messages from you.

Most ISPs and web hosting companies are tightening up their rules for relaying through their servers.

Javamail's session object has a setDebug(boolean) method.
If you set it to true, much of the SMTP traffic will be printed to stdout.
This can be helpful in when debugging SMTP settings.

I'm going to move this from JSP to Other Java APIs where JavaMail is discussed since this is not really a JSP specific issue.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Dhanya Palanisamy
Ranch Hand

Joined: Oct 20, 2006
Posts: 61
instead of using addRecipient(Message.RecipientType.TO, toAddress)
use setRecipient(Message.RecipientType.TO, toAddress)

might help
Dhanya Palanisamy
Ranch Hand

Joined: Oct 20, 2006
Posts: 61
Hi Talha,

props.put cannot have three parameters.You should modify like :

properties.put("mail.smtp.auth", "true");
properties.put("mail.smtp.user", "user");
properties.put("mail.smtp.password", "pass"
Henry Wong

Joined: Sep 28, 2004
Posts: 18997


Please do not start new topics to answer questions in current topics -- it is just confusing to everyone.

Anyway, the other topic contains a direct reply to Dhanya -- with the following message:

I am running it on my localhost Server although i have used your method but still i have the same problem. please m so confuse since yesterday please any one help me to solve this.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
It is sorta covered in the JavaRanch Style Guide.
subject: Please Help me to remove this SMTP Error