note 111340 added to function.mail

From: Date: Sat, 09 Feb 2013 02:09:39 +0000
Subject: note 111340 added to function.mail
Groups: php.notes 
Request: Send a blank email to php-notes+get-193563@lists.php.net to get a copy of this message
Somehow I had quite lot of problem sending multiparts mail using Windows 7 PHP and my ISP's SMTP server. First it could take more than hours before the mail was displayed and sometimes they were flagged as spam but this solved my problems. <?php function send_mail($email,$subject,$content) { $boundary = "PHP_".md5(uniqid()); $headers = ""; $message = ""; $headers .= "MIME-Version: 1.0".PHP_EOL; $headers .= "Content-Type: multipart/alternative; boundary=".Chr(34).$boundary.Chr(34).";". PHP_EOL . PHP_EOL; $message .= "--".$boundary.PHP_EOL; $message .= "Content-Type: text/plain; charset=".Chr(34)."UTF-8".Chr(34).";".PHP_EOL; $message .= "Content-Transfer-Encoding: base64". PHP_EOL .PHP_EOL; $message .= chunk_split(base64_encode($content['text'])).PHP_EOL; $message .= "--".$boundary.PHP_EOL; $message .= "Content-Type: text/html; charset=".Chr(34)."UTF-8".Chr(34).";".PHP_EOL; $message .= "Content-Transfer-Encoding: base64". PHP_EOL .PHP_EOL; $message .= chunk_split(base64_encode($content['html'])).PHP_EOL; $message .= "--".$boundary."--". PHP_EOL . PHP_EOL; return mail($email['to'],mb_encode_mimeheader($subject,"UTF-8"),$message,$headers,"-f ".$email['from']." -r ".$email['reply-to']); } ?> I hope it help someone. ---- Server IP: 69.147.83.199 Probable Submitter: 85.225.37.6 ---- Manual Page -- http://php.net/manual/en/function.mail.php Edit -- https://master.php.net/note/edit/111340 Del: integrated -- https://master.php.net/note/delete/111340/integrated Del: useless -- https://master.php.net/note/delete/111340/useless Del: bad code -- https://master.php.net/note/delete/111340/bad+code Del: spam -- https://master.php.net/note/delete/111340/spam Del: non-english -- https://master.php.net/note/delete/111340/non-english Del: in docs -- https://master.php.net/note/delete/111340/in+docs Del: other reasons-- https://master.php.net/note/delete/111340 Reject -- https://master.php.net/note/reject/111340 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#193563) next »