Scenario: Guitarist shares song with guitarist
Given the following user exists:
| name | email |
| Eric Clapton | eric@example.com |
And I sign in as "eric@example.com/password"
And I am on the share page for "Layla"
When I fill in "Share with" with "jimi@example.com"
And I press "Share Song"
And "jimi@example.com" opens the email
Then he should see "Eric Clapton" in the email "From" header
And he should see "eric@example.com" in the email "Reply-To" header

I think the “From” and “Reply-To” headers can provide a better user experience.

I don’t set the author’s email as the “From” header because I hear it’s bad
spam practice to send email on behalf of users in that way. ISPs use the From
header (among other things) to determine if the originator is sending spam.

I’ve used this format so the sender’s name shows up in the receiver’s email
program:

"Eric"

In this case, I want Jimi to be able to reply directly to Eric, so I’ve set the
“Reply-To” header to be the sender’s address. I’ve explicitly not put the
sender’s name in the “Reply-To” header because that doesn’t work.

In other cases, I want the receiver to reply to the email and have that sent
through the Rails app, but that’s a story for another day.

Want to level up your testing game?
Learn about testing Rails applications and TDD
in our new book
Testing Rails.
The book covers each type of test in depth,
intermediate testing concepts,
and anti-patterns that trip up even intermediate developers.