I’m working on a web application. A user will create an email message that will be sent to another person.
I would like the e-mail that gets sent to appear from the user’s name and e-mail address of the user on my system. And if they reply to the e-mail then it should go directly to the sender’s email address.
However I am worried about the email message looking like spam to email filters along the way.
Is there a proper way to do this?
I noticed on a ‘contact’ page on a WordPress blog that something very similar is done. The e-mail headers look like:
To: email@domain.com Subject: [Test Blog] =?UTF-8?B?aGVsbA==?= MIME-Version: 1.0 Content-Type: text/plain; charset='utf-8' From:=?UTF-8?B?aGVsbA==?=<sender@senderdomain.com> Message-Id: <20090207234737.39C9522802F3@web7.sat.wordpress.com> Date: Sat, 7 Feb 2009 23:47:37 +0000 (UTC) Return-Path: donotreply@wordpress.com
What is interesting is that the display name in the ‘from’ tag and the name that shows up in the subject line is encoded. I do not know if this helps with the spam filters or not, but thought it was at least worth mentioning.
Also, who would receive an undeliverable notification in this example? Would it go to sender@senderdomain.com or would it go to donotreply@wordpress.com?
Setting email fields is generally trivial, but the exact method of doing so depends on the language and framework you are using, which you don’t mention. Usually it is a matter of creating a new email object, and just doing something along the lines of:
You can set the specific from address to your user’s, if you like, it is not at all uncommon though I personally am not a fan. You could also set the from field to something like: ‘Sender Name (via Your Site Name) <yourresponseaddress@example.com>’.