I am sending email using Java Mail API. When the email is received in the inbox its shows the email address used to send the email. I want to hide the from email address and show some text. I think its possible because when I get an email from facebook, in the inbox it says "Facebook - Email subject" rather than "xyz@facebook.com - Email Subject".
I want to do the same using Java Mail API.
Thanks in advance. :)
Use the Constructor
InternetAddress(String address, String personal)
when building your sender address. In your example this would be
sender = new InternetAddress("xyz@facebook.com","Facebook");
Use this code inside the try block:
// Set From:
message.setFrom(new InternetAddress("displayname<"+from+">"));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.