Quick Tip : Specify a Human readable name for addresses in the Grails Mail Plugin

When using the grails mail plugin, you can specify names for senders by using this syntax:

"Firstname Surname<address@domain.com>"

i.e,

 mailService.sendMail({
          to "somedude@gmail.com"
          from "ali baba<fortythieves@arabia.com>"
          subject "hi"
          body "open sesame"
        }
  )

and it will show up in mailboxes as:


This allows us to show up in user mailboxes as a human readable name, instead of the typical noreply addresses.

You can even use it in config.groovy,

grails.mail.default.from = "ali baba<fortythieves@arabia.com>"

2 thoughts on “Quick Tip : Specify a Human readable name for addresses in the Grails Mail Plugin

  1. Roshan Shrestha

    Unless you happen to use GMail as your SMTP server.

    I believe GMail will use the actual account of the sender, and will display the sender’s actual account name in the email, irrespective of what you specify in the “from” field; i.e., using “ali baba” will still display your real name and email address and not what you specify, if your account is not “fortythieves@gmail.com”.

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s