note 13545 added to function.mail.php

From: Date: Thu, 21 Jun 2001 09:20:00 +0000
Subject: note 13545 added to function.mail.php
Groups: php.notes 
Request: Send a blank email to php-notes+get-14515@lists.php.net to get a copy of this message
Just a little bit of useful code that allows you to send html mail, the arguments being in my usual strange form (sorry) but they are in order (from,to,subject,htmlbody,textbody) Where textbody is optional an if omitted will be replaced with a plain text version of the htmlbody line function htmlmail($f,$t,$s,$h,$b = "UNSPECIFIED") { if ($b == "UNSPECIFIED") { $b = strip_tags($h); } $headers = "From: $f\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $q = uniqid("WblQ"); $headers .= "Content-Type: multipart/alternative" . "; boundary = $q\r\n\r\n"; $headers .= "This is a MIME encoded message.\r\n\r\n"; $headers .= "--$q\r\n" . "Content-Type: text/plain; charset=ISO-8859-1\r\n" . "Content-Transfer-Encoding: base64\r\n\r\n"; $headers .= chunk_split(base64_encode($b)); $headers .= "--$q\r\n" . "Content-Type: text/html; charset=ISO-8859-1\r\n" . "Content-Transfer-Encoding: base64\r\n\r\n"; $headers .= chunk_split(base64_encode($h)); mail($t, $s, "", $headers); } http://www.php.net/manual/en/function.mail.php

« previous php.notes (#14515) next »