0

hello sir,
i am new to jsp and i have to use jsp mail in my project and i got a jsp mail script but unfortunately it is showing error like this one!

530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://mail.google.com/support/bin/answer.py?answer=14257 f10sm3473193anh.25

i am using

smtp server:smtp.gmail.com

and there is no error except that i think it is connecting to smtp server because i tried by giveng a wrong server name and port,but i dont know what is authentication means...

here is my complete code

<%@ page language="java" import="javax.naming.*,java.io.*,javax.mail.*,
javax.mail.internet.*,com.sun.mail.smtp.*"%>

<html>
<head>
<title>Mail</title>
</head>

<body>

<%
try{
  Session mailSession = Session.getInstance(System.getProperties());
  Transport transport = new SMTPTransport(mailSession,new URLName("smtp.gmail.com"));
  transport.connect("smtp.gmail.com",587,"xxx@gmail.com","xxx");


  MimeMessage m = new MimeMessage(mailSession);
  m.setFrom(new InternetAddress(%><%request.getParameter("from")%><%));
  Address[] toAddr = new InternetAddress[] {
              new InternetAddress(%><%request.getParameter("to")%><%)
            };
  m.setRecipients(javax.mail.Message.RecipientType.TO, toAddr );
  m.setSubject(%><%request.getParameter("subject")%><%);
  m.setSentDate(new java.util.Date());
  m.setContent(%><%request.getParameter("description")%><%, "text/plain");
  transport.sendMessage(m,m.getAllRecipients());
  transport.close();
  out.println("Thanks for sending mail!");
}
catch(Exception e){

  out.println(e.getMessage());
  e.printStackTrace();
}
%>


</body>

</html>

friends please help me as soon as possible..
thanking u all!!!

Edited by pyTony: fixed formating

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by Phucok88
0

waste forum...no one is there to answer a simple question...
bye bye to daniweb.com...

0

you should set mail server, example:bestmailserver of firstmailserver.
If u test on localhost: u should change "transport.connect("smtp.gmail.com",587,"xxx@gmail.com","xxx");"
by : transport.connect("localhost",25,null,null);
I tried and success.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.