Traditionally, this was the purpose of the Sender
email header. If you want an email to be From
the user, but sent by you, you would just set the Sender
header to an email address on your domain but have From
be the user. Also, the SMTP envelope sender should also be on your domain. Then, you would be properly declaring that you're the sender of the message for anti-spam purposes, you'll receive any bounce messages, but email clients will know that the email is reportedly from the "real" user, and will direct replies accordingly. Generally, email clients would report both Sender and From, saying something like "From my-server@website.example.net on behalf of real-user@example.com", though obviously the details depend on the email client being used.
Refer to What's the difference between Sender, From and Return-Path? and OpenSPF Web Generated Email Best Practices for more information.
However, now DMARC has come along. It has made the decision that verification should be based only on the From
header. The theory is that there's no way for an end-user to know whether a particular Sender
is in fact authorized to send mail "on behalf of" the user listed in the From
header. While it probably isn't the decision I would have made due to how it ignores the traditional Sender
, it's something that needs to be dealt with now, as if the domain of the user listed in the From
has a DMARC record that is set to q=reject
, then nobody else, including your web form that's trying to send mail with the complete approval of the user, can send mail that's From
that domain. More and more domains are turning on DMARC, and as they do so your form won't be able to send email From
them, regardless of what other headers are set.
The only other alternative, then, is to have email be From
your application entirely, but set the Reply-To
header to where the email program should send replies to. Also, the SMTP envelope sender should be your application, and ideally be set to an address that can handle bounce messages or other errors. You shouldn't need to include any instructions, as the Reply-To
header is very well supported among email clients as indicating where replies should be directed.
Refer to the DMARC FAQ entry "Why are messages I send on behalf of visitors to my website being blocked?".