note 108368 deleted from function.mail by sobak

From: Date: Sat, 10 Dec 2016 10:39:23 +0000
Subject: note 108368 deleted from function.mail by sobak
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-208423@lists.php.net to get a copy of this message
Note Submitter: bimal at sanjaal dot com ---- 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)); ?>

« previous php.notes (#208423) next »