Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2008

Tip: Looking for answers? Try searching our database.

Error while sending email through JSP

Thread view: 
ruds - 17 Mar 2008 11:47 GMT
I'm trying to send email through JSP, here is my code:
<%@ page import="java.util.*, javax.mail.*, javax.mail.internet.*,
javax.activation.*, javax.mail.util.*, java.util.Properties" %>

<%
 String from_user="abc@gmail.com"; // for e.g.

  String toAddress = "rudranee@gmail.com";

  // out.println(from_user);
// out.println(toAddress);
 Properties props = new Properties();
 props.put("mail.smtp.host", "128.9.100.20");
Session ses = Session.getDefaultInstance(props, null);
    /*if (debug)
        ses.setDebug(true);*/

 MimeMessage message = new MimeMessage(ses);

 InternetAddress from = new InternetAddress(from_user);
 message.setFrom(from);

 InternetAddress to = new InternetAddress(toAddress);
 message.addRecipient(Message.RecipientType.TO, to);

 String subject = "FIR Query";
 message.setSubject(subject);
 String text = request.getParameter("msg");
 message.setText(text);
message.setContent(text, "text/html");

 Transport.send(message);
%>
<html>
<p align="center">The Message has been sent.</p>
<p align="center"><a href="./login.jsp">Click here to send another!</
a></p>
</html>

I'm getting error as;
javax.mail.SendFailedException: Invalid Addresses;
 nested exception is:
    com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to
relay for rudranee@gmail.com

What could be the problem?
Nigel Wade - 17 Mar 2008 12:34 GMT
> I'm trying to send email through JSP, here is my code:
> <%@ page import="java.util.*, javax.mail.*, javax.mail.internet.*,
[quoted text clipped - 42 lines]
>
> What could be the problem?

The mail server that you are connecting to (128.9.100.20) is refusing to relay
mail for the recipient address "rudranee@gmail.com".

Signature

Nigel Wade, System Administrator, Space Plasma Physics Group,
           University of Leicester, Leicester, LE1 7RH, UK
E-mail :    nmw@ion.le.ac.uk
Phone :     +44 (0)116 2523548, Fax : +44 (0)116 2523555

Roedy Green - 17 Mar 2008 13:04 GMT
>The mail server that you are connecting to (128.9.100.20) is refusing to relay
>mail for the recipient address "rudranee@gmail.com".

usually a SMTP server will refuse to forward mail for just anyone,
only mail for people at that domain.

You may have to logon.  see http://mindprod.com/products1.html#BULK 
using an "Authenticator".  See
http://mindprod.com/jgloss/authentication.html

It may only accept mail from certain IPs, e.g. ones serviced by the
ISP who owns the mail server.
Signature


Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.