You have a contact form that collects a person’s name and email address. When sending their email, you want to get these two pieces of information from looking like this:
Name: John Doe
Email: john@example.com
to this:
From: John Doe <john@example.com>
or:
Reply-To: John Doe <john@example.com>
If you simple concatenate strings, then you will either send a malformed email or introduce a security risk. Here’s a safe, proper way of doing it using the Mail gem: