want sample code for JavaMail Events

I have wriiten a simple code for sending mail.It works fine, but doesn't give any notification i.e. whether mail is deleivered or not ,wrong value for receiptant.

I guess Transport event class can be used for this puspose

I want sample code for JavaMail Events.

Please confirm whether i am correct or not?

if i am wrong plese give me another solution

i am attching part of my code

import java.util.*;

import java.io.*;

import javax.mail.*;

import javax.mail.internet.*;

class mailchk

{

public static void main(String[] args)

{

try{

String to="**************@sigmasoft.biz";

String from="*************@sigmasoft.biz";

String subject="cheking";

String message="this is a testing mail from java program";

System.out.println("Hello World!");

Properties props1 = new Properties();

props1.put("mail.transport.protocol", "smtp");

props1.put("mail.smtp.starttls.enable","true");

props1.put("mail.smtp.host", "193.168.1.4");

props1.put("mail.debug", "true" );

//Authenticator auth = (new mailchk()).new SMTPAuthenticator();

Session session = Session.getDefaultInstance(props1);

MimeMessage msg = new MimeMessage(session);

msg.setFrom(new InternetAddress(from));

msg.setRecipient(MimeMessage.RecipientType.TO, new InternetAddress(to));

msg.setSubject(subject);

msg.setSentDate(new Date());

msg.setContent(message, "text/plain");

Transport.send(msg);

}catch(MessagingException e )

{

System.out.println("exception occurs");

//e.printStackTrace();

System.out.println(e.getMessage().toString());

}

catch(Exception e )

{

System.out.println(" root exception occurs");

}

}

private class SMTPAuthenticator extends javax.mail.Authenticator

{

public PasswordAuthentication getPasswordAuthentication()

{

String username = "prithvirajm";

String password = "welcome";

return new PasswordAuthentication(username, password);

}

}

}

waitng for reply

[2161 byte] By [prithvi123a] at [2007-11-27 11:22:45]
# 1

Did you find the sample code that comes with JavaMail?

Did you find the JavaMail FAQ?

They'll answer your questions.

bshannona at 2007-7-29 14:56:40 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...