发送邮件用JavaMail没有用户名和密码 [英] Send mail with javamail without user and password
问题描述
我跟着这个帖子<一个href=\"http://stackoverflow.com/questions/2020088/sending-email-in-android-using-javamail-api-without-using-the-default-built-in-a\">Sending电子邮件在Android中使用JavaMail API不使用默认/内置应用发送邮件,而不意图。它工作正常。但我的问题是,如果你可以,而无需输入您的用户名和密码发送邮件?谢谢
I followed this post Sending Email in Android using JavaMail API without using the default/built-in app to send mails without intents. it works ok. but my question is if you can send mail without having to enter your user and password? thanks
推荐答案
不,你不能
你可以从code看到的,用户名
和密码
是用来登录到该邮件ID,然后是电子邮件ID
用于发送电子邮件
As you can see from the code, The username
and password
is used to login to that mail ID and then that Email ID
is used to send the Email
该GMailSender有一个构造函数中的用户名和密码,这是用来创建一个登录会话在code
The GMailSender has a constructor that takes in the username and password, this is used to create a login session as in code
session = Session.getDefaultInstance(props, this);
一旦登录已经完成,现在您发送从邮件ID电子邮件如您在浏览器中通常做
Once the login has been done now your sending the Email from that mail ID as you normally do in browser
替代的
Alternatives
现在,如果你想发送电子邮件,那么你可以在这样的android发送意图
Now if you want to send a email then you can send an intent in android like this
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_EMAIL, new String[]{"youremail@gmail.com"});
email.putExtra(Intent.EXTRA_SUBJECT, "subject");
email.putExtra(Intent.EXTRA_TEXT, "message");
email.setType("message/rfc822");
startActivity(Intent.createChooser(email, "Choose an Email client"));
但这将弹出用户与选择的客户端的从电子邮件具有要发送
But this would pop up the user with the choice of client from which email has to be sent
或
如果你甚至不想使用这一点,那么我会建议创建自己的 Web服务器
,使 HTTP
要求它通过服务器发送电子邮件
If you even dont want to use this, then I would suggest creating your own webserver
and make HTTP
request to it to send Emails via the server
这篇关于发送邮件用JavaMail没有用户名和密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!