• 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 ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • 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");

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");


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

Please Help me to solve this Problem
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"
Posts: 23883
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.

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
    Bookmark Topic Watch Topic
  • New Topic