Step 1 - Inside server portal-ext.properties add this
mail.session.mail.imap.host=192.99.42.143
mail.session.mail.pop3.host=192.99.42.143
mail.session.mail.smtp.auth=true
mail.session.mail.smtp.host=smtp.gmail.com
mail.session.mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory
mail.session.mail.smtp.socketFactory.fallback=false
mail.session.mail.smtp.socketFactory.port=465
mail.session.mail.smtp.starttls.enable=true
mail.session.mail.smtp.password=muhammedsaleem
mail.session.mail.smtp.port=465
mail.session.mail.smtp.user=callsaleem@gmail.com
mail.session.mail.store.protocol=imap
mail.session.mail.transport.protocol=smtp
Step 2 - Restart the server
Step 3 - Open build.gradle
Add this line: compile 'javax.mail:mail:1.4.7'
Step - 4 Create Send mail method in controller
public void sendMailWithPlainText() {
InternetAddress fromAddress = null;
InternetAddress toAddress = null;
try {
fromAddress = new InternetAddress("xyz@gmail.com");
toAddress = new InternetAddress("abc@gmail.com");
MailMessage mailMessage = new MailMessage();
mailMessage.setTo(toAddress);
mailMessage.setFrom(fromAddress);
mailMessage.setSubject("Your Bill is claimed successfully");
mailMessage.setBody("Hi,<br>Your content<br><br>Best Regards,<br>Mufas");
mailMessage.setHTMLFormat(true);
MailServiceUtil.sendEmail(mailMessage);
System.out.println("Send mail with Plain Text");
} catch (AddressException e) {
e.printStackTrace();
}
}
Step -5 : Call the send mail method
sendMailWithPlainText()
mail.session.mail.imap.host=192.99.42.143
mail.session.mail.pop3.host=192.99.42.143
mail.session.mail.smtp.auth=true
mail.session.mail.smtp.host=smtp.gmail.com
mail.session.mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory
mail.session.mail.smtp.socketFactory.fallback=false
mail.session.mail.smtp.socketFactory.port=465
mail.session.mail.smtp.starttls.enable=true
mail.session.mail.smtp.password=muhammedsaleem
mail.session.mail.smtp.port=465
mail.session.mail.smtp.user=callsaleem@gmail.com
mail.session.mail.store.protocol=imap
mail.session.mail.transport.protocol=smtp
Step 2 - Restart the server
Step 3 - Open build.gradle
Add this line: compile 'javax.mail:mail:1.4.7'
Step - 4 Create Send mail method in controller
public void sendMailWithPlainText() {
InternetAddress fromAddress = null;
InternetAddress toAddress = null;
try {
fromAddress = new InternetAddress("xyz@gmail.com");
toAddress = new InternetAddress("abc@gmail.com");
MailMessage mailMessage = new MailMessage();
mailMessage.setTo(toAddress);
mailMessage.setFrom(fromAddress);
mailMessage.setSubject("Your Bill is claimed successfully");
mailMessage.setBody("Hi,<br>Your content<br><br>Best Regards,<br>Mufas");
mailMessage.setHTMLFormat(true);
MailServiceUtil.sendEmail(mailMessage);
System.out.println("Send mail with Plain Text");
} catch (AddressException e) {
e.printStackTrace();
}
}
Step -5 : Call the send mail method
sendMailWithPlainText()
No comments:
Post a Comment