package com.mail;
import javax.mail.*;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
public class EmailSender {
public static void main(String ar[]) throws Exception{
String smtpHost = "smtp.mail.yahoo.com",
user = "aaa@aa.com",
password = "1234",
to ="csnair1981@yahoo.com",
subject="hi how r u ",
fromName = "abcd@gmail.com";
java.util.Properties props = new java.util.Properties();
props.put("mail.smtp.host", smtpHost);
props.put("mail.smtp.auth", "true");
props.put("mail.transport.protocol", "http");
props.put("mail.pop.port", 587);
// Authenticator auth = new PopupAuthenticator ();
Session session = Session.getInstance(props);
// Address replyToList[] = { new InternetAddress("csnair1981@yahoo.com") };
Address toList[] = { new InternetAddress("csnair1981@yahoo.com") };
Message newMessage = new MimeMessage(session);
newMessage.setFrom(new InternetAddress(fromName));
// newMessage.setReplyTo(replyToList);
newMessage.setRecipient(Message.RecipientType.TO, new InternetAddress(to));
newMessage.setSubject(subject);
newMessage.setText("This is is a test mail from java ");
// newMessage.setSentDate(sentDate);
Transport transport = session.getTransport("smtp");
transport.connect(smtpHost, user, password);
transport.sendMessage(newMessage, toList);
}
}
Saturday, December 12, 2009
Send Email program full source code
7:11 PM
Karthikh Venkat
Popular Posts( Last 7 Days )
-
எதுக்குடா இந்த மானங்கெட்ட பிழைப்பு இந்த விஜய் பிச்சகாரனுக்கு......?????? இந்த பிச்ச முத்து , மக்களுக்கு பசுமாடு குடுக்கராராமா ....? யாரு...
-
Registering your Domain name in BigRock is a great idea. BigRock.com is providing lots and lots of great facilities. And Domai...
-
Asus G73 Gaming Rog nVidia GeForce GTX 3D graphics with 460 offers 1.5 GB of GDDR5 memory and supports NVIDIA 3D Vision, and comes with N...
-
wwe wallpapers,wwe stills, wwe posters,wwe latest picture photo posters collections, batista latest pictures wallpapers posters news recent
-
Hello guys, Are you looking for a final year Students free projects with source code and Documentation?. If yes, you are in an ex...
-
Computer Virus Basics What is a computer virus? Simply put, it is a program that reproduces. When it is executed, it simply makes one or mor...