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


Popular Posts( Last 7 Days )
-
Prateik Babbar & Aamir Khan on the cover of Man's World, Aamir Khan on the cover of Man's World Magazine, Prateik Babbar on the...
-
1,76,652,00,00,000. ஒரு சராசரி இந்தியன் இந்தத் தொகையைக் குழப்பமின்றி எழுத்துக் கூட்டிக் கணக்கிட சில நிமிஷங்கள் ஆகும். இந்தியத் தொலைத்தொடர...
-
Final squads of the 14 participating teams: Australia: Ricky Ponting (capt), Michael Clarke, Doug Bollinger, Brad Haddin, John Hastings,...
-
Melyssa Ford hot wallpapers Melyssa Ford wallpapers Melyssa Ford wallpaper
-
Actress Anjali,Monica at Muthuku Muthaga Movie Audio Launch,tamil actress anjali new cute stills at muthuku muthaga music launch function g...