Setting an alias for FROM email address for JavaMail

I recently needed to set an alias for FROM email address when I was sending an email via JavaMail (i.e. when the receipient opens up his email, I didn’t want the FROM email to show up as ivetic@xxxx.com, but I wanted them to see it as “Aleks Ivetic” instead).

If you try to do pass “Aleks Ivetic” directly as FROM field, you will get this error: javax.mail.internet.AddressException: Illegal whitespace in address in string ” Aleks Ivetic

You should format the FROM field like this instead:   “Aleks Ivetic<aleksivetic@xxxxx.com>”

This entry was published on December 17, 2008 at 3:38 pm and is filed under Java/J2EE. Bookmark the permalink. Follow any comments here with the RSS feed for this post.

Leave a comment