1 Reply Latest reply on Apr 19, 2007 8:52 PM by 807596

    New to java mail please help ..

      Hi all

      iam new to java mail technology.
      Here is the class that i have used to send mail.My requirement is whenever user completes a registration , a confirmation mail is tyo be send to him automatically.

      How can i identify mail server and its SMTP address? Please help.

      sendmail.sendEmail(); This is the method i have called in the servlet.

      mail class

      package org.kran.hris.domain;
      import java.util.Date;
      import java.util.Properties;

      import javax.mail.Message;
      import javax.mail.MessagingException;
      import javax.mail.Session;
      import javax.mail.Transport;
      import javax.mail.internet.InternetAddress;
      import javax.mail.internet.MimeMessage;
      * @author kran
      * TODO To change the template for this generated type comment go to
      * Window - Preferences - Java - Code Style - Code Templates
      public class sendMail {

           public void sendEmail()
                System.out.println("Inside mail class");
                String host="smtp.mail.yahoo.com";
                String from="jakri_007@yahoo.com";
                String to="jkrishnanj@gmail.com";
                String username="linukumar";
                String password="password";
                Properties props = new Properties();
                Session session = Session.getInstance(props);
                     System.out.println("Inside mail class2");
                Message msg=new MimeMessage(session);
                msg.setFrom(new InternetAddress(from));
                InternetAddress fromaddr = new InternetAddress(to);
                msg.setSubject("Test email through JAVA");
                msg.setSentDate(new Date());
                System.out.println("Inside mail class3");
                msg.setText("Test email for HRIS application from java application using java mail");
                Transport bus=session.getTransport("smtp");
                System.out.println("Inside mail class4");
                catch (MessagingException msex)

      Any body please help........