6

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.

Asaph
  • 159,146
  • 25
  • 197
  • 199
cupakob
  • 8,411
  • 24
  • 67
  • 76

1 Answers1

7

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.

Asaph
  • 159,146
  • 25
  • 197
  • 199
  • works with yahoo, but not with google. It seems to be a bug/feature in google (http://coding.derkeiler.com/Archive/Java/comp.lang.java.programmer/2008-05/msg02294.html). – cupakob Oct 12 '09 at 21:34
  • @cupakob: If Google doesn't allow Reply-to, you just might be out of luck using Google's SMTP server for outgoing email. Is it not an option to run your own SMTP server for outbound email? Perhaps QMail or Postfix? – Asaph Oct 12 '09 at 21:54
  • @Asaph: not in this case, i will use this app rarely (maybe once every 2-3 months). I can leave without gmail recipients ;) – cupakob Oct 12 '09 at 22:01
  • @cupakob:"gmail recipients"? There is no limitation on recipients. Just senders. – Asaph Oct 12 '09 at 22:29
  • This is wrong with PHP, I am setting the from address other than the SMTP auth account mail id, It works fine, I think the way of setting the from address in java can be done in different way, You can refer my post [here](http://stackoverflow.com/questions/14811540/setfrom-of-java-mail-api-is-not-working-properly) – n92 Feb 12 '13 at 08:10