/ Email

A small robust android library for sending emails using SMTP server

A small robust android library for sending emails using SMTP server

Maildroid

Maildroid is a small robust android library for sending emails using SMTP server.

show

Library is using Oracle Java Mail API to handle connections and sending emails.

Key Features

  • Sending emails using SMTP protocol :incoming_envelope:
  • Compatible with all smtp providers :tada:
  • Sending HTML/CSS styled emails :art:
  • Library is using Java Mail API that is well known as best library for sending emails :telescope:

Add to your project

Maildroid is hosted on JitPack and it's quite easy to integrate in to your project.
Maildroid requires at least Android API level 19 Android KitKat

How do you want to integrate Maildroid into your project

Gradle

Add this to your root.gradle file

allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}

Add dependency


dependencies {
	        implementation 'com.github.nedimf:maildroid:v0.0.2-alpha'
          }

Maven

Add the JitPack repository to your build file

<repositories>
   <repository>
       <id>jitpack.io</id>
       <url>https://jitpack.io</url>
    </repository>
</repositories>

Add the dependency


<dependency>
     <groupId>com.github.nedimf</groupId>
     <artifactId>maildroid</artifactId>
     <version>v0.0.2</version>
</dependency>

Add to your app

Adding Maildroid to your app is straight forword process. Library is using Builder pattern to achieve flexebilty and easy to read wholesome implementation:

  MaildroidX.Builder()
            .smtp("")
            .smtpUsername("")
            .smtpPassword("")
            .smtpAuthentication()
            .port("")
            .type(MaildroidX.HTML)
            .to("")
            .from("")
            .subject("")
            .body("")
            .attachment("")
	    //or
	    .attachments() //List<String>
	    .onCompleteCallback(object : MaildroidX.onCompleteCallback{
		override val timeout: Long = 3000
		override fun onSuccess() {
  			Log.d("MaildroidX",  "SUCCESS")			  
		}
		override fun onFail() {
			 Log.d("MaildroidX",  "FAIL")
		}
	     })
	     .mail()

DSL implementation:

sendEmail {
      smtp("smtp.mailtrap.io")
      smtpUsername("username")
      smtpPassword("password")
      smtpAuthentication(true)
      port("2525")
      type(MaildroidXType.HTML)
      to("[email protected]")
      from("[email protected]")
      subject("Hello!")
      body("email body")
      attachment("path_to_file/file.txt") 
      //or
      attachments() //List<String>
      callback {
          timeOut(3000)
          onSuccess {
              Log.d("MaildroidX",  "SUCCESS")
          }
          onFail {
              Log.d("MaildroidX",  "FAIL")
          }
      }
 }

Documentation


Documentation for version v.0.0.2-alpha

  • smtp

Constructor that is used to declare SMTP server your will use (String)

  • smtpUsername

Constructor that is used to declare SMTP username of your server (String)

  • smtpPassword

Constructor that is used to declare SMTP password of your server (String)

  • smtpAuthentication

Constructor that is used to declare if your server needs authentication (Boolean)

  • port

Constructor that is used to declare port of your server (String)

  • type

Constructor that is used to declare type of your content (MaildroidXType)

  • MaildroidXType.HTML
  • MaildroidXType.PLAIN
  • to

Constructor that is used to declare internet adress where email will be send (String)

  • from

Constructor that is used to declare internet adress witch email is sent from. It s fully supporting @no_replay or not existent email adresses (String)

  • subject

Constructor that is used to declare subject of email your sending (String)

  • body

Constructor that is used to declare body of email your sending (String)

  • attachment

Constructor that is used to declare attachment of email in case that ones need to be added (String)

  • attachments

Constructor that is used to declare unlimited number attachments into email (List)

  • onCompleteCallback ()

When sending email is done, call this constructor to handle further actions in your app.
Constructor is made out of two functions

  • onSuccess() that handles when email is succssfully sent
  • onFail() that handles any error in sending email
  • timeout value that is used to predict timout how long will it take for email to be sent defualt is 3 seconds (Long)
  • mail ()

Function that is called when email is ready to be sent

Errors


Maildroid is handling small amount of exceptions.

IllegalArgumentException


These exceptions are called after an error in checking if mandatory fields are not existent.

  • MaildroidX detected that you didn't pass [smtp] value in to the builder!
  • MaildroidX detected that you didn't pass [smtpAuthentication] value to the builder!
  • MaildroidX detected that you didn't pass [port] value to the builder!

AuthenticationFailedException


These exceptions are called when username or password on SMTP server is not correct, or address of SMTP server is not existent.

  • MaildroidX detected that you didn't pass [smtpUsername] or [smtpPassword] to the builder!
  • MaildroidX detected that you didn't pass [smtpUsername] or [smtpPassword] to the builder!

Other

  • SMTPAddressFailedException

Thrown when mail can't be sent

  • MessagingException

Thrown when there is problem with message

  • IOException

File in attachment not found or not existent

Development

We love open source :hearts:

Contributing to our project is really easy if you follow these steps.

  • Add maildroidx to your machine

    • Download maildroid folder
    • Open it on your machine using your favourite IDE (Android Studio / InteliJ ) is recomended
  • Contribution :tada:

    • Fork the repository
    • Create new branch git checkout -b maildroidx-community-features
    • Add your feature or other changes to files
    • Commit your changes git commit -m 'New feature'
    • Push to the branch git push origin maildroidx-community-features
    • Create a pull request

Bug :bug:


We are trying to make this library as bug free as possible ,but as you know some bugs can occure. If you find bug or typo in our library be free to open issue and report it.

  • Open issue
    • bug

    Explaining bug is most important thing please use standard english language and don't forget to share your debug log

    • typo

Feature Request


We strive to make maildroid best mailing library out there. We have ideas to add, but we would also like to hear from you.

  • Open issue
    • fetaure

Built with :muscle:


  • Kotlin
  • Java Mail API / Jakarta Mail API by Eclipse foundation

TODO


Team

nedimf javier-moreno

Your name here :hearts:

Motivation

Maildroid was born from the frustration of implementing a good emailing solution I had while developing a few client apps. I had to do many hours of unneeded work to make some emailing functions work using old libraries. Those libraries were limited to one SMTP server and because of that frustration Maildroid was born..

GitHub