Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Please Help me to remove this SMTP Error

 
Talha-bin -Shakir
Ranch Hand
Posts: 32
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is My Code.

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

<%
Properties props = new Properties();

props.put("mail.smtp.host","true", "localhost");

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

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


InternetAddress toAddress = new InternetAddress("hussaintalha@gmail.com");

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

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

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

Transport.send(message);
%>

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

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

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 hussaintalha@gmail.com

Please Help me to solve this Problem
Thanxs
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Dhanya Palanisamy
Ranch Hand
Posts: 61
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
instead of using addRecipient(Message.RecipientType.TO, toAddress)
use setRecipient(Message.RecipientType.TO, toAddress)

might help
 
Dhanya Palanisamy
Ranch Hand
Posts: 61
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author
Marshal
Pie
Posts: 20836
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Talha-Bin,

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.


Henry
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic