Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaMail API, Gmail-Auth and setFrom

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("[email protected]"));

[email protected] 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.

like image 924
cupakob Avatar asked Oct 12 '09 21:10

cupakob


People also ask

Is JavaMail deprecated?

The App Engine Mail API (which also supports JavaMail) has already been deprecated. Instead, GCP recommends to use a third-party mail provider such as: SendGrid.

What is the SMTP port number for Gmail?

The outgoing SMTP server, smtp.gmail.com , requires TLS. Use port 465 , or port 587 if your client begins with plain text before issuing the STARTTLS command.


1 Answers

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.

like image 62
Asaph Avatar answered Oct 11 '22 06:10

Asaph