gmail-sender-library

Additional

Language
Java
Version
N/A
Created
Nov 16, 2018
Updated
Dec 17, 2019 (Retired)
Owner
Khang Tran (tntkhang)
Contributors
Khang Tran (tntkhang)
Ifta Noor Mahmood (iftalab)
2
Activity
Badge
Generate
Download
Source code

Advertisement

This library help you to sent email by gmail

Setup

  1. Add to build.gradle in app level
implementation 'com.github.tntkhang:gmail-sender-library:1.3.0'
  1. How to use it
   GMailSender.withAccount("your-email@gmail.com", "email-password")
                .withTitle(title)
                .withBody(body)
                .withSender(getString(R.string.app_name))
                .toEmailAddress(emailAddress) // one or multiple addresses separated by a comma
                .withListenner(new GmailListener() {
                    @Override
                    public void sendSuccess() {
                        Toast.makeText(MainActivity.this, "Success", Toast.LENGTH_SHORT).show();
                    }

                    @Override
                    public void sendFail(String err) {
                        Toast.makeText(MainActivity.this, "Fail: " + err, Toast.LENGTH_SHORT).show();
                    }
                })
                .send();
  1. IMPORTANT ! Enable less secure for the email using to sent email: https://support.google.com/accounts/answer/6010255?hl=en
  2. Add those line into pro-guard
# Required for GmailSender
-dontwarn java.awt.**
-dontwarn java.beans.Beans
-dontwarn javax.security.**
-keep class javamail.** {*;}
-keep class javax.mail.** {*;}
-keep class javax.activation.** {*;}
-keep class com.sun.mail.dsn.** {*;}
-keep class com.sun.mail.handlers.** {*;}
-keep class com.sun.mail.smtp.** {*;}
-keep class com.sun.mail.util.** {*;}
-keep class mailcap.** {*;}
-keep class mimetypes.** {*;}
-keep class myjava.awt.datatransfer.** {*;}
-keep class org.apache.harmony.awt.** {*;}
-keep class org.apache.harmony.misc.** {*;}
  1. Enjoy

Checkout example if you need a demo.