Hi, thanks for looking.

The problem is that I can't get a custom header in my emails no matter what i do. The code i have is shown below. From everything I have read it seems like it should work.

I have also had a chat with my host (Hostmonster.com) and the little form that the guy made to test it works, so it is definately possible. THey aren't blocking etc.

Any help at all is appreciated.

$to  = 'rickya100@gmail.com';

// subject
$subject = 'It\'s your turn to debate!';

// message
$message = '
  <title>Add to the debate</title>
<tr bgcolor="#193441"><td><img alt=\'thinksane.net\' src=\'http://www.thinksane.net/images/logo.png\' /></td></tr>
<h3>It\'s your turn to add to the debate!</h3>
<h4>Hello name,</h4>
<p>This is an email to let you know that it is now your turn to post a comment in the ever continuing debate at ThinkSane.net.</p>

<h4>Your activation code is: 00000</h4>

<h4>Here\'s some tips on what to write &amp; how to structure it in case you\'re not sure...</h4>
       	<li>READ the last few comments before starting to write your own.</li>
        <li>Try and respond to any points of contention that the previous commenter raised and then put forth any arguments that you wish to raise.</li>
        <li>Spell check your finished comment. Use your favourite service or try <a href="http://www.spelljax.com/" title="Spell Check">this one</a></li>
        <li>Make sure your comment adheres to the rules. NO excessive cursing, NO purely offensive comments and NO purely site promotion comments.</li>
<h4>We look forward to seeing what you have to say!</h4>

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'To: Ricahrd <rickya100@gmail.com>' . "\r\n";
$headers .= 'From: admin@thinksane.net' . "\r\n";

// Mail it
mail($to, $subject, $message, $headers);
10 Years
Discussion Span
Last Post by rickya100

Change your code to have the From: at the top of the $headers like this.
Also, removed the To: in the $headers, as it is entered in another variable in the mail() function.

// To send HTML mail, the Content-type header must be set
$headers  = 'From: admin@thinksane.net' . "\r\n"; //notice how the From: is first?
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

You may also want to personalize your From: field like this:

$headers  = 'From: Think Sane Administration <admin@thinksane.net>' . "\r\n";


Thanks for the advice. Unfortunately the emails i send still don't have a custom From: address.

Any other ideas you have would be great as I am clean out of solutions.

Here is the code with the From address set first.

// To send HTML mail, the Content-type header must be set and additional header (ie from:)
$headers = 'From: ThinkSane.net Administrator <admin@thinksane.net>' . "\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Mail it
mail($to, $subject, $message, $headers);
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.