Search code examples
javasmtpgmailsmtp-auth

How do you send messages from a different address using Gmail and Java?


I'm using Java to send messages from Gmail with Apache Commons Email, but it seems like it doesn't allow me to send messages from an address different from the one that I use to authenticate.

How do you send messages from a different address using Gmail and Java?


Solution

  • Basically, you are looking for an SMTP server which will let you send a message by spoofing the From MIME header. Well, if you can't find a hosted SMTP server online, you can always install one locally on your box. This will allow you to modify the email address of the sender to make it appear as if it is coming from gmail.