Click here to Skip to main content
15,125,299 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i tried this coding,,

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";
String to ="receiver mail id";

// Get system properties
Properties props = System.getProperties();

// Setup mail server
props.put("mail.smtp.host", host);


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");

// Send message
Transport.send(message);
  %>


But i got error as shown below..


type Exception report

message

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

exception

javax.servlet.ServletException: javax.mail.AuthenticationFailedException: failed to connect, no password specified?
root cause

javax.mail.AuthenticationFailedException: failed to connect, no password specified?
note The full stack traces of the exception and its root causes are available in the GlassFish v3 logs.
Posted
Updated 4-Feb-12 2:36am
v2

See the documentation for JavaMail API[^]. Give it a try and when you have a more specific problem come back here with some more detail.
   
jGuru: Fundamentals of the JavaMail API[^]

E-Mailing Through Java[^]

You might want to read both. Also please use a local emailserver on your machine for testing. Most real pop3 servers are only allowing a couple of contacts each 15 min.

http://www.hmailserver.com/[^] is free and easy to use. Please be aware that also this service has an auto-ban function -> "Settings" -> "Advanced"
   

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