Two Laptop Bag*
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


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
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
Author

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("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

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
author
Sheriff

Joined: Sep 28, 2004
Posts: 18765
    
  40

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


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Please Help me to remove this SMTP Error