PHP mail() function and From Header


Yes, I knew you wanted to read about another development on the PHP mail function front. So here it is: you can use the “from” header on some servers and not on others. Some mailservers will reject an email with a “from” header (with out of state plates) out of hand, on the possibility it is spam. Others will allow you to send a message with it.

Why do I need to include the “From” header in a mail message? As previously explained, I am developing a universal contact module that can be included on any website. Not all that complicated…you would think. But as my dear old granddad used to say between spits of tobacco, “It’s always sumpin’.”

I wanted to make it easy to respond to messages sent by the contact form, so I included the “From” and “reply to” headers. It worked fine on one server, and I thought, great, now I will just start installing this module on all my sites. The first one liked the “From” module, so did the second, but when I hit a different server, it did not like it.

As it turns out, you don’t really need the ”From” header in the email to allow a one click response form to show up on your email program. So, I have simply removed it. The “reply to” still works fine.

  1. No comments yet.

You must be logged in to post a comment.