From 72040b54ae56b19c7f611ec085d0fd28ca09cd39 Mon Sep 17 00:00:00 2001 From: jens Date: Sat, 3 Oct 2026 18:08:22 +0200 Subject: [PATCH] send emails --- app/build.gradle | 6 ++-- .../java/com/jens/automation2/Actions.java | 28 +++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 254f5df..e63d54d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -61,12 +61,12 @@ android { lint { abortOnError false checkReleaseBuilds false - } + dependencies } namespace 'com.jens.automation2' buildToolsVersion '36.0.0' } -dependencies { + { implementation 'org.jetbrains:annotations:26.1.0' googlePlayFlavorImplementation 'com.google.firebase:firebase-appindexing:20.0.0' googlePlayFlavorImplementation 'com.google.android.gms:play-services-location:20.0.0' @@ -77,6 +77,8 @@ dependencies { implementation 'com.linkedin.dexmaker:dexmaker:2.28.6' implementation 'org.apache.commons:commons-lang3:3.20.0' + implementation 'org.simplejavamail:simple-java-mail:9.3.5' + //implementation "androidx.security:security-crypto:1.0.0" //implementation "androidx.security:security-identity-credential:1.0.0-alpha02" implementation 'androidx.appcompat:appcompat:1.4.2' diff --git a/app/src/main/java/com/jens/automation2/Actions.java b/app/src/main/java/com/jens/automation2/Actions.java index 2367459..dbdf6da 100644 --- a/app/src/main/java/com/jens/automation2/Actions.java +++ b/app/src/main/java/com/jens/automation2/Actions.java @@ -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); + } } \ No newline at end of file