发布于 2015-05-10 10:04:40
我认为你要求的是出站发件人的电子邮件,这是类似于邮件。其中一个类似的服务是Amazon,它已经被合并到AWS SDK中。它甚至有一个不错的教程来实现它的安卓系统。SES和Mailgun都需要经过验证的发件人,所以从技术上讲,您将发送来自您自己的域的电子邮件,并且与用户的电子邮件无关。
发布于 2015-11-24 15:32:47
发送邮件基本实现,通过MailGun API和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();
}
}完整Github要点:https://gist.github.com/hpsaturn/5fd39a4e7d6ffb156197
发布于 2015-05-10 08:14:20
我建议使用javamail。它对我来说很好,在android上也很好。下面是到google代码项目的链接。虽然您没有像mailgun那样有太多的可能性,但是仅仅发送一封javamail就足够了。
https://stackoverflow.com/questions/30148833
复制相似问题