0

Not sure if this is possible. We send emails in our Spring Boot application, using MessageHelper we set the FROM. However, when the email is received we see a different from in the mail client.

So I can understand why, but we were hoping it might be possible to show a different value.

We use Gmail as the sender and have a Gmail account that the emails get sent from, so it has an email address that we will call myaccount@gmail.com We use that address in the

spring.mail.username=myaccount@gmail.com

In the code we set the From via either MimeMessage or MimeMessageHelper, but in the end they update the same MimeMessage instance.

messageHelper.setFrom("support@mycompany.com");
message.setFrom("support@mycompany.com");

If the message gets sent and looking at the recipients mail client it show in the From column "myaccount@gmail.com". But we want it to show support@mycompany.com

I know technically the email message is sent from the myaccount@gmail.com and in the headers it can show that, but for the UI we want to show support@mycompany.com

bytor99999
  • 726
  • 7
  • 26
  • 2
    afaik you cannot, as it is gmail that in the end is altering the actual from address. – M. Deinum Jun 15 '17 at 17:47
  • That's what I figured, but wanted to get a second opinion. – bytor99999 Jun 15 '17 at 18:01
  • Related: https://stackoverflow.com/questions/5431631/when-using-gmail-for-smtp-can-you-set-a-different-from-address and https://stackoverflow.com/questions/1332510/how-to-change-from-address-when-using-gmail-smtp-server. Was thinking about voting to close as a duplicate, because even though it mentions PHP, the answer applies here as well. – g00glen00b Jun 16 '17 at 06:51
  • I think, in the end, it is a duplicate. Only because the end result is that it is Gmail that puts the From value, regardless of programming language being used. – bytor99999 Jun 16 '17 at 15:37

0 Answers0