note 108368 added to function.mail

From: Date: Fri, 20 Apr 2012 05:05:56 +0000
Subject: note 108368 added to function.mail
Groups: php.notes 
Request: Send a blank email to php-notes+get-187253@lists.php.net to get a copy of this message
You can write clean PHP code while creating the headers correctly. First, build a list of all headers in an array. Then, glue them with "\r\n" character. The code now looks clean and straight forward. (Just compare it with the manual's example ;-) ) <?php $headers = array(); $headers[] = "MIME-Version: 1.0"; $headers[] = "Content-type: text/plain; charset=iso-8859-1"; $headers[] = "From: Sender Name <sender@domain.com>"; $headers[] = "Bcc: JJ Chong <bcc@domain2.com>"; $headers[] = "Reply-To: Recipient Name <receiver@domain3.com>"; $headers[] = "Subject: {$subject}"; $headers[] = "X-Mailer: PHP/".phpversion(); mail($to, $subject, $email, implode("\r\n", $headers)); ?> ---- Server IP: 69.147.83.197 Probable Submitter: 27.50.11.131 ---- Manual Page -- http://www.php.net/manual/en/function.mail.php Edit -- https://master.php.net/note/edit/108368 Del: integrated -- https://master.php.net/note/delete/108368/integrated Del: useless -- https://master.php.net/note/delete/108368/useless Del: bad code -- https://master.php.net/note/delete/108368/bad+code Del: spam -- https://master.php.net/note/delete/108368/spam Del: non-english -- https://master.php.net/note/delete/108368/non-english Del: in docs -- https://master.php.net/note/delete/108368/in+docs Del: other reasons-- https://master.php.net/note/delete/108368 Reject -- https://master.php.net/note/reject/108368 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#187253) next »