Skip to content

Instantly share code, notes, and snippets.

@jpmckinney
Created November 12, 2011 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpmckinney/1360883 to your computer and use it in GitHub Desktop.
Save jpmckinney/1360883 to your computer and use it in GitHub Desktop.
How to safely create friendly From addresses including name and email
# blog post: http://blog.slashpoundbang.com/post/12695434343/how-to-safely-create-friendly-from-addresses-including
require 'mail'
# You already have +name+ and +email+ from the contact form.
address = Mail::Address.new email # john@example.com
address.display_name = name # John Doe
# Set the From or Reply-To header to the following:
address.format # John Doe <john@example.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment