Click here to Skip to main content
16,021,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i tried this coding to send mail by using my aol mail account..but i got error

XML
<%@page import ="java.sql.*" %>
       <%@ page import="java.io.*,java.util.*,javax.mail.*"%>
<%@ page import="javax.mail.internet.*,javax.activation.*"%>
<%@ page import="javax.servlet.http.*,javax.servlet.*" %>
<%
String host="", user="", pass="";

host ="smtp.aol.com"; //"smtp.gmail.com";
user="my mail id@aol.com";
pass="password";

String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";

String to ="receiver mail id@gmail.com"; // out going email id

String from ="my mail id@haol.com"; //Email id of the recipient

String subject ="hi how are you";

String messageText ="hi how are you";


boolean sessionDebug = true;

Properties props = System.getProperties();
props.put("mail.host", host);
props.put("mail.transport.protocol.", "smtp");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.", "true");
props.put("mail.smtp.port", "587");
props.put("mail.smtp.starttls.enable","true ");
props.put("mail.smtp.socketFactory.fallback", "false");
props.put("mail.smtp.socketFactory.class", SSL_FACTORY);
Session mailSession = Session.getDefaultInstance(props, null);
mailSession.setDebug(sessionDebug);
Message msg = new MimeMessage(mailSession);
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = {new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject(subject);
msg.setContent(messageText, "text/html"); // use setText if you want to send text
Transport transport = mailSession.getTransport("smtp");
transport.connect(host, user, pass);
transport.sendMessage(msg, msg.getAllRecipients());
out.print("<script>alert('Message Sent Successfully')</script>");
transport.close();

%>



but i got the following error..

CSS
type Exception report

message

descriptionThe server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: javax.mail.MessagingException: Could not connect to SMTP host: smtp.aol.com, port: 587;
  nested exception is:
    javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
root cause

javax.mail.MessagingException: Could not connect to SMTP host: smtp.aol.com, port: 587;
  nested exception is:
    javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
root cause

javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?


what port number should i use to resolve this problem..
Posted

You are not using SSL correctly; see here[^].
 
Share this answer
 
Did you consider going to the pages for these servers, or googling this info ?
 
Share this answer
 
Comments
mahalakshmikamaraj 4-Feb-12 12:51pm    
i didnt understand your question
Christian Graus 4-Feb-12 13:26pm    
The question is, who on earth would ask this here, instead of going to the hotmail page on the web and getting the info for themselves ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900