import javax.mail.*;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import java.util.Date;
import java.util.Properties;
public class GmailSendEmailSSL {
public static final String USERNAME = "xxxxxxxxxxxxxxxx";
public static final String PASSWORD = "xxxxxxxxxxxxxxxx";
public static void main(String[] args) throws Exception {
//
// Email information such as from, to, subject and contents.
//
String mailFrom = "xxxxxxxxxxxxxxxxxxxxxx";
String mailTo = "xxxxxxxxxxxxxxxxxxxxxxxxxxx";
String mailSubject = "TestReport";
String mailText = "Please check enclosed TestReport";
GmailSendEmailSSL gmail = new GmailSendEmailSSL();
gmail.sendMail(mailFrom, mailTo, mailSubject, mailText);
}
private void sendMail(String mailFrom, String mailTo,
String mailSubject, String mailText)
throws Exception {
Properties config = createConfiguration();
//
// Creates a mail session. We need to supply username and
// password for Gmail authentication.
//
Session session = Session.getInstance(config, new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(
GmailSendEmailSSL.USERNAME,
GmailSendEmailSSL.PASSWORD
);
}
});
//
// Creates email message
//
Message message = new MimeMessage(session);
message.setSentDate(new Date());
message.setFrom(new InternetAddress(mailFrom));
message.setRecipient(Message.RecipientType.TO, new InternetAddress(mailTo));
message.setSubject(mailSubject);
message.setText(mailText);
//
// Send a message
//
Transport.send(message);
}
private Properties createConfiguration() {
return new Properties() {{
put("mail.smtp.host", "smtp.gmail.com");
put("mail.smtp.auth", "true");
put("mail.smtp.port", "465");
put("mail.smtp.socketFactory.port", "465");
put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
}};
}
}
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import java.util.Date;
import java.util.Properties;
public class GmailSendEmailSSL {
public static final String USERNAME = "xxxxxxxxxxxxxxxx";
public static final String PASSWORD = "xxxxxxxxxxxxxxxx";
public static void main(String[] args) throws Exception {
//
// Email information such as from, to, subject and contents.
//
String mailFrom = "xxxxxxxxxxxxxxxxxxxxxx";
String mailTo = "xxxxxxxxxxxxxxxxxxxxxxxxxxx";
String mailSubject = "TestReport";
String mailText = "Please check enclosed TestReport";
GmailSendEmailSSL gmail = new GmailSendEmailSSL();
gmail.sendMail(mailFrom, mailTo, mailSubject, mailText);
}
private void sendMail(String mailFrom, String mailTo,
String mailSubject, String mailText)
throws Exception {
Properties config = createConfiguration();
//
// Creates a mail session. We need to supply username and
// password for Gmail authentication.
//
Session session = Session.getInstance(config, new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(
GmailSendEmailSSL.USERNAME,
GmailSendEmailSSL.PASSWORD
);
}
});
//
// Creates email message
//
Message message = new MimeMessage(session);
message.setSentDate(new Date());
message.setFrom(new InternetAddress(mailFrom));
message.setRecipient(Message.RecipientType.TO, new InternetAddress(mailTo));
message.setSubject(mailSubject);
message.setText(mailText);
//
// Send a message
//
Transport.send(message);
}
private Properties createConfiguration() {
return new Properties() {{
put("mail.smtp.host", "smtp.gmail.com");
put("mail.smtp.auth", "true");
put("mail.smtp.port", "465");
put("mail.smtp.socketFactory.port", "465");
put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
}};
}
}
It’s really amazing that we can record what our visitors do on our site. Thanks for sharing this awesome guide. I’m happy that I came across with your site this article is on point,thanks again and have a great day. Keep update more information..
ReplyDeleteCRO Agency in Chennai
Its a really great post.
ReplyDeleteBest SAP Training in Bangalore
Best Java Training in Bangalore
Informative post.I got more knowledge from this blog.Thanks for sharing.... Warehouse Audit
ReplyDeleteStock Audit
Customer Reconciliation
Nice Blog i can easily understand with coding
ReplyDeleteselenium training centers in Bangalore
best software testing training institutes in Bangalore with placements
automation testing courses in Bangalore
selenium testing course in Bangalore
software testing institutes in Bangalore
selenium training in Bangalore
best selenium training in Bangalore
selenium course in Bangalore
Nice blog
ReplyDeletetableau course in Marathahalli
best tableau training in Marathahalli
tableau training in Marathahalli
tableau training in Marathahalli
tableau certification in Marathahalli
tableau training institutes in Marathahalli
I really enjoyed your blog Thanks for sharing such an informative post.Looking For Some More Stuff.
ReplyDeleteshuttering works
such an amazing content.
ReplyDeletePackers and movers
Movers and packers
Packers and movers in gurgaon
Packers and movers in Delhi
Packers and movers in Noida
Wonderful write-up! I learned several new things from this blog.workday hr training
ReplyDeleteAfter comparing several options for the best powerbi training online, I found OnlineITGuru to be a strong choice because of its experienced trainers, live projects, and certification support.best power bi training online
ReplyDeleteOnline Tableau Training makes it easy to master dashboard creation, data analysis, and reporting without attending physical classes. A structured curriculum, live instructor support, and project-based learning help learners understand Tableau concepts more effectively. It's a valuable investment for anyone planning a career in analytics or business intelligence.online tableau training
ReplyDeleteThe article provides some valuable insights into learning data visualization tools. A structured tableau online course can be particularly helpful for learners who want to progress from basic charts to more advanced dashboards. Thanks for the useful information.tableau online course
ReplyDeleteOracle Service Bus training helps professionals understand how to integrate applications and manage enterprise services efficiently. This oracle service bus training covers proxy services, business services, pipelines, adapters, message transformation, and service monitoring. Students strengthen their skills through hands-on exercises and real-world scenarios.
ReplyDelete