note 106157 modified in function.mail by danbrown

From: Date: Fri, 14 Oct 2011 14:02:59 +0000
Subject: note 106157 modified in function.mail by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-183881@lists.php.net to get a copy of this message
If you are getting frustrated that your email is being sent as plain text instead of HTML, typically one of your headers showing up in the email (even if other scripts on the same server seem to work fine!!!) then structure your headers like this: <?php $headers = 'From: You <you@example.com>' . "\n"; $headers .= 'MIME-Version: 1.0' . "\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; ?> Notice that the From is before the MIME and Content and only Content ends with "\r\n", the other are just "\n" Not sure how it is possible for other scripts on the same server, same domain to work fine as shown in the very top instructions, and others need this crap... I spent a very frustrating couple hours figuring this out, hope you can avoid doing the same. --was-- If you are getting frustrated that your email is being sent as plain text instead of HTML, typically one of your headers showing up in the email (even if other scripts on the same server seem to work fine!!!) then structure your headers like this: $headers = 'From: You <you@mail.com>' . "\n"; $headers .= 'MIME-Version: 1.0' . "\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; Notice that the From is before the MIME and Content and only Content ends with "\r\n", the other are just "\n" Not sure how it is possible for other scripts on the same server, same domain to work fine as shown in the very top instructions, and others need this crap... I spent a very frustrating couple hours figuring this out, hope you can avoid doing the same. http://php.net/manual/en/function.mail.php

« previous php.notes (#183881) next »