Send mail with android without using smtp and user interaction

I want to send an email from my Android application without user intervention. How can I implement services such as Mailgun API in android?

I found a code snippet in mailgun that works in java . For this implementation, I got libraries that does not work with android. Has anyone tried using mailgun in android?

+1
android email mailgun
source share
4 answers

I think you are asking if the sender is an email sender similar to Mailgun. One such service is Amazon SES, which is already included in the AWS Mobile SDK . It even has a nice tutorial to implement it on Android. Both SES and Mailgun require a confirmed sender, so technically you will send emails from your own domain and have nothing to do with the user's email.

+1
source share

Send Mail the base implementation, through the MailGun API and Retrofit for Android:

public class MailGun { private static final String TAG = MailGun.class.getSimpleName(); private static final boolean DEBUG = Config.DEBUG; private static final String ENDPOINT = "https://api.mailgun.net/v3/yourdomain.com/"; public static final String ACCEPT_JSON_HEADER = "Accept: application/json"; public static final String BASIC = "Basic"; private SendMailApi sendMailApi; public interface SendMailApi { @Headers({ACCEPT_JSON_HEADER}) @FormUrlEncoded @POST("/messages") void authUser( @Header("Authorization") String authorizationHeader, @Field("from") String from, @Field("to") String to, @Field("subject") String subject, @Field("text") String text, Callback<MailGunResponse> cb ); } public void sendMail(String to, String subject, String msg, Callback<MailGunResponse> cb){ String from = "User Name Maybe < mailgun@yourdomain.com >"; String clientIdAndSecret = "api" + ":" + "key-AdFEFtggxxxYourApiKey"; String authorizationHeader = BASIC + " " + Base64.encodeToString(clientIdAndSecret.getBytes(), Base64.NO_WRAP); sendMailApi.authUser(authorizationHeader,from, to, subject, msg, cb); } public MailGun() { RestAdapter restAdapter = getAuthAdapter(); sendMailApi = restAdapter.create(SendMailApi.class); } private RestAdapter getAuthAdapter(){ RestAdapter.LogLevel logLevel = RestAdapter.LogLevel.NONE; if(DEBUG)logLevel = RestAdapter.LogLevel.FULL; return new RestAdapter.Builder() .setEndpoint(ENDPOINT) .setConverter(new GsonConverter(new Gson())) .setLogLevel(logLevel) .build(); } } 

Finish Github gist: https://gist.github.com/hpsaturn/5fd39a4e7d6ffb156197

+1
source share

I would suggest using javamail. It works great for me and works on Android. Here is a link to the google code project . Although you do not have as many features as in mailgun, just sending javamail mail is enough.

0
source share
 let key = "dfasewr4353terf34t43fefdf34r" let EmailBody = "<html><body><table border='1'><tr><td>Jill</td><td>Smith</td><td>50</td></tr><tr>td>Eve</td><td>Jackson</td><td>94</td></tr><tr><td>John</td><td>Doe</td><td>80</td></tr></table></body></html>" let parameters = [ "from": from@fromme.com , "to": to@tome.com , "subject": "my Email Subject", "html": EmailBody, "text" = "some text instead of html.Only one is aloowed either text or HTML" ] Alamofirerequest(.POST, "https://api.mailgun.net/v3/<MAILGUN-DOMAIN>/messages", parameters:parameters) .authenticate(user: "api", password: key) .response { (request, response, data, error) in println(request) println(response) println(error) } 
0
source share

All Articles