• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Please Help me to remove this SMTP Error

 
Ranch Hand
Posts: 32
  • 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
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • 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.
 
Ranch Hand
Posts: 61
  • 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
  • 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"
 
author
Posts: 23883
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • 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
 
Getting married means "We're in love, so let's tell the police!" - and invite this tiny ad to the wedding:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic