send emails

This commit is contained in:
jens committed 2026-10-03 18:08:22 +02:00
1 parent ab2b0ce34c
commit 72040b54ae
2 files changed
+32 -2

No files matched your search

@@ -2675,4 +2675,32 @@ public class Actions
android.provider.Settings.Secure.putString(context.getContentResolver(), android.provider.Settings.Secure.LOCATION_MODE, String.valueOf(desiredState));
}
public static sendEmail()
{
Properties props = new Properties();
props.put("mail.smtp.host", smtpHost);
props.put("mail.smtp.port", "587");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.connectiontimeout", "10000");
props.put("mail.smtp.timeout", "10000");
Session session = Session.getInstance(props, new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(fromAddress));
message.setRecipients(
Message.RecipientType.TO,
InternetAddress.parse(recipientAddress)
);
message.setSubject(subject);
message.setText(body);
Transport.send(message);
}
}