Skip to content
Snippets Groups Projects
Commit 0bdcf18a authored by Kenneth Ezekiel's avatar Kenneth Ezekiel
Browse files

add: mailer done

parent 858c2f1b
No related merge requests found
......@@ -17,43 +17,36 @@ public class Mailer {
static final String password = dotenv.get("MAILER_PASS", "mail-pw");
// configuration settings for the SMTP server
// static final Properties props = new Properties() {
// {
// put("mail.smtp.auth", "true");
// put("mail.smtp.starttls.enable", "true");
// put("mail.smtp.host", System.getenv().getOrDefault("MAILER_HOST", "smtp.gmail.com"));
// put("mail.smtp.port", System.getenv().getOrDefault("MAILER_PORT", "465"));
// }
// };
// session object from jakarta mail API
// static final Session session = Session.getInstance(props,
// new Authenticator() {
// protected PasswordAuthentication getPasswordAuthentication() {
// return new PasswordAuthentication(username, password);
// }
// });
static final Properties props = new Properties() {
{
put("mail.smtp.host", "sandbox.smtp.mailtrap.io");
put("mail.smtp.port", "2525");
put("mail.smtp.auth", "true");
put("mail.smtp.starttls.enable", "true");
put("mail.smtp.starttls.required", "true");
put("mail.smtp.ssl.trust", "sandbox.smtp.mailtrap.io");
put("mail.username", username);
put("mail.password", password);
put("mail.smtp.EnableSSL.enable", "true");
put("mail.smtp.host", dotenv.get("MAILER_HOST"));
put("mail.smtp.port", dotenv.get("MAILER_PORT"));
}
};
// session object from jakarta mail API
static final Session session = Session.getInstance(props, new jakarta.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
// static final Properties props = new Properties() {
// {
// put("mail.smtp.host", "sandbox.smtp.mailtrap.io");
// put("mail.smtp.port", "2525");
// put("mail.smtp.auth", "true");
// put("mail.smtp.starttls.enable", "true");
// put("mail.smtp.starttls.required", "true");
// put("mail.smtp.ssl.trust", "sandbox.smtp.mailtrap.io");
// put("mail.username", username);
// put("mail.password", password);
// }
// };
public static void sendMail(String to, String subject, String textMsg) {
try {
// create new email
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment