Reputation: 531
I am trying to send an email to a specific address by using my own email.
So far, I know that I can use android.content.Intent.ACTION_SEND
to send an email. For istance:
final Intent emailIntent = new
Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
new String[]{"[email protected]"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
"Log-in Sucessful");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Hi");
Activity context = null;
context.startActivity(Intent.createChooser(emailIntent, "Send mail..."));
However, I do not know whether ACTION_SEND
can accept username and password as well. This username and password basically will be used to authenticate the email sender. It's just like when you need to log-in into your gmail account before you can compose and send an email to someone.
Do you guys by any chance know any solution/guide to do this?
Thank you guys in advance
Upvotes: 1
Views: 1439
Reputation: 48871
CommonsWare got to it before me but what he/she said. :D
Basically ACTION_SEND is simply a 'generic' send intent(ion) and that's the point of the chooser. Example...if I pick a contact on my phone to send email to, I get a choice of using a 'Mail' app (SMTP/POP3/IMAP4) or the GMail app. In either case, I've configured these apps with username/password details and where necessary, the incoming/outgoing server details needed.
In short, username/password are useless as ACTION_SEND doesn't explicitly know which outgoing server those details apply to.
From what I can tell, you want to automate this entirely which suggests you need to create your own SMTP client code which you can pass username/password and server details along with the message.
Upvotes: 2
Reputation: 1007296
However, I do not know whether ACTION_SEND can accept username and password as well.
No, it does not, nor should it. The email client must have an email account configured.
Upvotes: 1