I am writing a shell script to setup a few servers and once it is done, it will send an email to our help desk letting us know that the server is ready to be used.

I would like to use the following subject line: New Space Loop Activated! 🎉

But I cannot for the life of me figure out how to make accept that emoji. I can use emojis on the email body, but it does not work on the subject.

# Send an email to let us know that the server is ready to be used.
# Credentials will be sent to Vault instead of being stored on the server
# once the Vault server has been properly configured.
# @since 0.0.1
mail -s 'New Space Loop Activated!' \
-a 'From:Kerb!am Man<kerblam@domain.tld>' help@domain.tld << END_MAIL
Delivery for The Humans,

Your new space loop ($HOSTNAME) has been configured $(printf '\xf0\x9f\x8e\x89') and credentials are
available at /home/gatekeeper/. Please remove them from the server once they
have been placed in a secure location.

Delivery fulfilled,
Kerb!am Man $(printf '\xf0\x9f\xa4\x96\n')

And remember: if you want it, Kerblam it!

I have tried a few ideas:

  • Tried using encoded-character, but it does not seem to work for shell scripts — or I am too stupid to figure it out
  • Tried using unicode and utf-8
  • Tried using printf and echo

But nothing seems to work. Is that even supported? I am using postfix and mailutils, with Postmark as the SMTP relay.


The character 🎉 in UTF-8 is:

f0 9f 8e 89

So you need this string in the subject line:


or for the whole subject:

New Space Loop Activated! =?utf-8?Q?=F0=9F=8E=89?=

The sequence means character set is utf-8 and the Q means quoted-printable encoding. You can also use BASE64 encoding to save a few bytes.

  • Great, that worked! Do you know where I can find documentation for this? I would like to read more on it. – James Pond Jun 5 at 19:52
  • See ietf.org/rfc/rfc2047.txt – RalfFriedl Jun 5 at 19:58
  • Perfect, thank you! – James Pond Jun 5 at 20:10
  • works in ubuntu 18.04 LTS :D not working in Red Hat 4.8.5-36 :(. subject reads: "New Space Loop Activated! ␦" when arriving in my inbox. I'll try checking and updating posfix and mailutils – HyperActive Oct 9 at 7:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.