import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.Message.
RecipientType;
import javax.mail.internet. AddressException;
import javax.mail.internet. InternetAddress;
import javax.mail.internet. MimeMessage;
import com.sun.mail.smtp. SMTPSSLTransport;
public class SendMailExample {
public static void main(String[] args)throws Exception {
String host = "smtp.gmail.com";
String from = "sheo.hclcdc@gmail.com";
String pass ="Your Password";
Properties props = System.getProperties();
props.put("mail.smtp.starttls. enable", "true"); // added this line
props.put("mail.smtp.host", host);
props.put("mail.smtp.user", from);
props.put("mail.smtp.password" , pass);
props.put("mail.smtp.port", "587");
props.put("mail.smtp.auth", "true");
String[] to = {"shivsriv@gmail.com","triptis hukla29@gmail.com"}; // added this line
Session session = Session.getDefaultInstance( props, null);
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
InternetAddress[] toAddress = new InternetAddress[to.length];
// To get the array of addresses
for( int i=0; i < to.length; i++ ) { // changed from a while loop
toAddress[i] = new InternetAddress(to[i]);
}
System.out.println(Message. RecipientType.TO);
for( int i=0; i < toAddress.length; i++) { // changed from a while loop
message.addRecipient(Message. RecipientType.TO, toAddress[i]);
}
message.setSubject(" Notification Mail");
message.setText("Welcome !!!!......This is Automated Mail \nThanks & Regards \n sheo");
Transport transport = session.getTransport("smtp");
transport.connect(host, from, pass);
transport.sendMessage(message, message.getAllRecipients());
transport.close();
}
}
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.Message.
import javax.mail.internet.
import javax.mail.internet.
import javax.mail.internet.
import com.sun.mail.smtp.
public class SendMailExample {
public static void main(String[] args)throws Exception {
String host = "smtp.gmail.com";
String from = "sheo.hclcdc@gmail.com";
String pass ="Your Password";
Properties props = System.getProperties();
props.put("mail.smtp.starttls.
props.put("mail.smtp.host", host);
props.put("mail.smtp.user", from);
props.put("mail.smtp.password"
props.put("mail.smtp.port", "587");
props.put("mail.smtp.auth", "true");
String[] to = {"shivsriv@gmail.com","triptis
Session session = Session.getDefaultInstance(
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
InternetAddress[] toAddress = new InternetAddress[to.length];
// To get the array of addresses
for( int i=0; i < to.length; i++ ) { // changed from a while loop
toAddress[i] = new InternetAddress(to[i]);
}
System.out.println(Message.
for( int i=0; i < toAddress.length; i++) { // changed from a while loop
message.addRecipient(Message.
}
message.setSubject("
message.setText("Welcome !!!!......This is Automated Mail \nThanks & Regards \n sheo");
Transport transport = session.getTransport("smtp");
transport.connect(host, from, pass);
transport.sendMessage(message, message.getAllRecipients());
transport.close();
}
}
good one
ReplyDeletetrabzon
ReplyDeleteçorum
sinop
yozgat
afyon
KEMSZ