Hi all... I get an error that says :
nested exception: Messaging Exception : 553... Domain name required.
I am writing my code below. could someone plesae tell me where I have gone
wrong?
Thanks!!
package akshodhan;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.mail.*;
import javax.mail.internet.*;
public class mailquer extends HttpServlet
{
private String smtpHost;
private String defaultFrom;
private Session session;
//Initialize the servlet with the host name of the SMTP server
//to send the messages..not hard-coded, but passing the init parameter
public void init(ServletConfig config)
throws ServletException
{
super.init(config);
smtpHost = "email.mycgiserver.com";
} // end of init
public void doPost(HttpServletRequest request,HttpServletResponse response)
throws ServletException, IOException
{
response.setContentType("text/html");
java.io.PrintWriter writer= response.getWriter();
String status="status start";
//this.getServletContext().log("MY PERSONAL LOG ENTRY" + ": "
+ request.getServletPath());
writer.println("<html><body>");
String from="Webmaster";
//request.getParameter("from");
String to="[EMAIL PROTECTED]";
//request.getParameter("to");
String cc="";
// request.getParameter("cc");
String bcc="";
// request.getParameter("bcc");
String subject="";
// request.getParameter("subject");
String text ="no sugar";
//request.getParameter("text");
try{
//Create the Javamail session
java.util.Properties properties = System.getProperties();
properties.put("mail.smtp.host",smtpHost);
Session session=Session.getInstance(properties,null);
//Construct a message
MimeMessage message=new MimeMessage(session);
//setting the from address
message.setFrom(new InternetAddress(from));
// for multiple recipients
message.setRecipients(Message.RecipientType.TO,InternetAddress.parse(to));
status=status+"sending... ";
//message.setRecipients(Message.RecipientType.CC,InternetAddress.parse(cc));
//message.setRecipients(Message.RecipientType.BCC,InternetAddress.parse(bcc));
message.setSubject(subject);
message.setText(text);
// sending the message
Transport.send(message);
status=status+"your message has been sent.";
}
catch(Exception ex)
{
status="Error : " + ex.toString();
}
//Output a status message
response.setContentType("text/html");
writer.println("status:" + status + "</body></html>");
writer.close();
}
}
____________________________________________________________________
Get free email and a permanent address at http://www.amexmail.com/?A=1
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html