Android: Send mails not intent!

how to send Email from the android application without using intent in Rx-isstyle!

You can just crash into my repo and see the code for the app to skip big ass explanation and check the code and figure out how the things are working.


Welcome to the post. Follow along and enjoy!

In this project, I have used Java-Mail-API which is used to create-read-write emails. we would be consuming and packages to send an email to an admin account.

Project Setup :

Grab a copy of main.jar, activation.jar, additional.jar from

Since we would make use of reactive extensions, get latest libraries from


adding files to project :

For .jar dependencies

  1. Switch to project view.
  2. Expand to app folder and paste your into libs folder.
  3. Open project level gradle build and the following file dependencies:
// paste in dependencies of project level gradle build file
implementation files('libs/mail.jar')
implementation files('libs/activation.jar')
implementation files('libs/additional.jar')
or //but for some reason this wasn't including mail.jar (above one was working fine for me)
implementation fileTree(dir: 'libs', include: ['*.jar'])

For dependencies paste the Rx libraries in the same, project level gradle build file.

implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
implementation "io.reactivex.rxjava2:rxjava:2.2.8"

Implementing the Black-Mailer…

Java Mail API uses Four objects to send a mail,

  1. Properties: this object configured the email host and the port.
  2. Session: creates a session using properties and require username and password.
  3. Message: is type where you compose your email.
  4. Transport: Use to send the message.

Step 1

Make a configuration/util/constant storing class to store email and password of the admin.

object Config {    
val EMAIL = "YourADminEmail"
val PASSWORD = "YpurAdminPassword"

Step 2

Creating our Completable observer which handles mail sending mechanism.

In this demo, I will be using as my mailing server.

Step 3

Consuming our completable.

Mailer.sendMail("","test-mail-subject",               "dummy test from android app")
{ Toast.makeText(this@EmailActivity, "Mail send check e-mail", Toast.LENGTH_SHORT).show()},
{ Timber.e(it) // or log.e("BlackMailin",e)}

That’s All Folks!

P.s. checkout my blogger, maybe you discover something new!


NOTE: if you will use google email as admin you need to enable permission for security lesser-secure apps from the settings of the admin Gmail. Else Gmail will block the access and you will get authorization exception.

Here is the shortcut to enable that setting. (Make sure your login with admin email)

Coding enthusiast! love Android #kotlinAlltheWay, want to explore all opportunity around it! CodingMantra: #cleanCoder #TDD #SOLID #designpatterns

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store