A friend asked me about how can you send a email without using Intents, focused in send an email without user intervention, so we searched and found out that Jon Simon did a great job implementing a wrapper for JavaMail for Android, so i though we should build a Library to ease this work.
First, you need to add the EasyMail.jar
, then you can create a instance of EasyMail:
EasyMail mail = new EasyMail(user, password);
which receives two parameters, the user of your account like "[email protected]" and your password as Strings. Now you need to pass some more parameters like:
`String[] directionsToSend = {"[email protected]", "[email protected]"};
mail.setTo(directionsToSend);
mail.setFrom("[email protected]");
mail.setSubject("This is a test.");
mail.setBody("This is an email sent using my Mail JavaMail wrapper from an Android device.");`
Finally, you need to send the email, so we do the next:
`try {
if(mail.send()) {
//Say sent
} else {
//Say not sent
}
} catch(Exception e) {
//Print StackTrace
}`
And that's all!
You need to add three more libraries for JavaMail: activation.jar
, additional.jar
and mail.jar
.
Version 0.1, which helps you send emails without using Intents. Pull requests are well received!
Feel free to clone this project and run in your IDE to see how can be implemented :).
You can contact me via StackOverflow, using the message system from Github or via email: [email protected]