a small library to send a email in background without user interaction.
This Library was originally made by Yesid Lazaro LINK
Under Licensed to the Apache Software Foundation (ASF) http://www.apache.org/licenses/LICENSE-2.0
Project - build.gradle(app)
For External Use implementation project
dependencies {
implementation project(':gmailbackgroundlibrary')
}
Project - settings.gradle
include ':app', ':gmailbackgroundlibrary'
Gradle via Jetpack
repositories {
maven { url "https://jitpack.io" }
}
AndroidManifist (Android Permissions)
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
To able to use attachment you need set READ_EXTERNAL_STORAGE permission in your manifiest
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
Proguard
-keep class org.apache.** { *; }
-dontwarn org.apache.**
-keep class com.sun.mail.** { *; }
-dontwarn com.sun.mail.**
-keep class java.beans.** { *; }
-dontwarn java.beans.**
BackgroundMail.newBuilder(this)
.setUsername("[email protected]")
.setPassword("password12345")
.setSenderName("SenderName")
.setMailTo("[email protected]")
.setMailCc("[email protected], [email protected]")
.setSubject("this is the subject")
.setBody("this is the body")
.OnSuccessCallback(new BackgroundMail.OnSuccessCallback() {
@Override
public void onSuccess() {
//do some magic
}
})
.OnFailCallback(new BackgroundMail.OnFailCallback() {
@Override
public void onFail() {
//do some magic
}
})
.send();
Functions | Description |
---|---|
setUsername |
Set Sender Username (@String/int) |
setPassword |
Set Sender Password (@String/int) |
setSenderName |
Set Sender Name (@String) |
setMailTo |
Set Mail to specific Email Address (@String/int) |
setMailCc |
Set Mail CC (@String/int) |
setMailBcc |
Set Mail BCC (@String/int) |
setSubject |
Set Mail Subjects (@String/int) |
setBody |
Set Mail Body (@String/int) |
setType |
Set Email Type can be Plain or HTML Style (@String/int) |
setAttachments |
Set Email Type can be Plain or HTML Style (@Arraylist/String) |
setSendingMessage |
Set Mail Sending Message (@String/int) |
Callbacks | Description |
---|---|
OnSendingMessageSuccess |
If setSendingMessage was Success sent |
OnSendingMessageError |
If setSendingMessage was Failed or Something went wrong |
setProcessVisibility |
Set Process (true/false) |
OnSuccessCallback |
If Mail was Succesfully Sent to MailTo |
OnFailCallback |
If Mail was Failed to sent |
This Library is already refactored to AndroidX
Project Gradle 2.14.1 - Upgraded to Gradle Wrapper 3.0 REFERENCE: https://services.gradle.org/distributions/gradle-3.0-bin.zip
After Upgraded to Wrapper 3.0 - Updated to Gradle Wrapper 4.8 due to incompatible with Java 11 or newer
Android Gradle Plugin Version: 7.0.0 Nougat
Gradle Version: 7.3.3
minSdkVersion: 11 - minSdkVersion: 14
**BUILD GRADLE APP**
targetSdkVersion: 25 - targetSdkVersion: 31
compileSdkVersion: 25 - compileSdkVersion: 31
buildToolsVersion "25.0.1" - buildToolsVersion "25.0.3"
**LIST OF DEPENDENCIES THAT BEING UPDATED TO LATEST LIBRARIES & ADDED NEW LIBRARIES**
junit:junit:4.12 - junit:junit:4.13.2
androidx.appcompat:appcompat:1.0.0 - androidx.appcompat:appcompat:1.4.1
com.google.android.material:material:1.0.0 - com.google.android.material:material:1.5.0
androidx.annotation:annotation:1.0.0 - androidx.annotation:annotation:1.3.0
**REQUIRED INSTRUMENTED TEST**
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
**LIBRARY UTIL UPDATES**
UTF8 Changed to StandardCharsets.UTF_8 can be used instead
Cipher.getInstance should not be called without setting the encryption mode and padding
Cipher cipher = Cipher.getInstance("DES"); - Suppressed @SuppressLint("GetInstance") Cipher cipher = Cipher.getInstance("DES");