Click here to Skip to main content
16,019,089 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i tried this coding to send mail from jsp program using my hotmail account..

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 ="smtp.live.com";
String from ="my hotmail email id@hotmail.com";
String to ="receiver mail id.com";
String pass="my hotmail password ";
// Get system properties
Properties props = System.getProperties();

// Setup mail server
props.put("mail.smtp.host", host);
props.put("mail.smtp.user","myid@hotmail.com");

props.put("mail.smtp.password","mypassword");
Session msession = Session.getDefaultInstance(props, null);

// Define message
MimeMessage message = new MimeMessage(msession);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO,
  new InternetAddress(to));
message.setSubject("Hello JavaMail");
message.setText("Welcome to JavaMail");
Transport tr = msession.getTransport("smtp");
            tr.connect(host, from, pass);
// Send messa
            tr.send(message);
// Send message

  %>



but i got error as shown below


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 convert socket to TLS;
  nested exception is:
    java.io.IOException: Server is not trusted: smtp.live.com
root cause

javax.mail.MessagingException: Could not convert socket to TLS;
  nested exception is:
    java.io.IOException: Server is not trusted: smtp.live.com
root cause

java.io.IOException: Server is not trusted: smtp.live.com
note The full stack traces of the exception and its root causes are available in the GlassFish v3 logs.




how can i resolve this error..
Posted

1 solution

Sorry but I would suggest to not use hotmail account for sending mail

use yahoo or Google


read below blog and compair your code with this

http://bytes.com/topic/java/answers/16139-send-mails-via-jsp-servlets[^]
 
Share this answer
 

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