JavaMail API, Gmail-Auth and setFrom

荒凉一梦 提交于 2019-12-04 01:24:12

问题


for this app i'm following this example:

http://pipoltek.blogspot.com/2008/02/sending-mail-using-gmail-smtp-server.html

I can send emails, it looks good.....but i want to modify the sender email using this:

MimeMessage msg = new MimeMessage(mailSession);
msg.setFrom(new InternetAddress("baba-jaga@gmail.com"));

baba-jaga@gmail.com is dummy E-Mail, is not mine :)

When t use setFrom, i recive the email from this email, which i use to authenticate. Is the authentication the reason, which disable the setFrom method?

I need to change the "from" email, because i want, that the recipient send me an replay to another email adress.


回答1:


Google's SMTP server is preventing using a from address other than the one belonging to the account that has been authenticated. This is a security measure to prevent what is known as "spoofing". Perhaps you can try setting the reply-to to another value and see if Google will allow that.



来源:https://stackoverflow.com/questions/1557000/javamail-api-gmail-auth-and-setfrom

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!