Abi K
Abi K

Reputation: 17

How to send mail in background using other host not gmail host in Android?

I am making one app that app forgot password time sending mail background to particular mail id. It's working Gmail to another mail (include gmail also) but our client need client domain id to other mail (Example [email protected] using background sending mails) it's possible i try many times mail not send but i get one error message in logcat

javax.mail.AuthenticationFailedException link used in browser that time display warning

Upvotes: 0

Views: 169

Answers (1)

Matt
Matt

Reputation: 5684

public class SendMessageService extends Service{
  public void sendMessage(){
    Intent send = new Intent(Intent.ACTION_SENDTO);
    String uriText = "mailto:" + Uri.encode("[email protected]") + 
      "?subject=" + Uri.encode("the subject") + 
      "&body=" + Uri.encode("the body of the message");
    Uri uri = Uri.parse(uriText);
    send.setData(uri);
    startActivity(Intent.createChooser(send, "Send mail..."));
  }
}

There are some key things you should know about services you can read about here. Most of this code is taken from this example, but you should be able to tailor it to fit your needs.


Edit 1:

This may also be a duplicate of this question, but there are some differences.

Upvotes: 0

Related Questions