Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

Mail from a php script correctly showing in TB, not in Mail

the mail() function

Moderators: macek, egami, gesf

Mail from a php script correctly showing in TB, not in Mail

Postby fbartolom » Thu May 24, 2012 12:52 am

Hullo,
I have a script that sends an email upon the completion of a form entrance. The sent message is correctly shown when viewed on Thunderbird but when viewed on Mail, either on a Mac or an iPhone, it is left totally uninterpreted. You may see the email by completing the form at:
http://www.miafoto.it/iPhone/inarrivo/php/sweepstake/
and this is the snippet of code performing the operation:

Code: Select all
if ($email=="") exit;
$to = $email;
//define the subject of the email
//create a boundary string. It must be unique
//so we use the MD5 algorithm to generate a random hash
$random_hash = md5(date('r', time()));
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: info@inarrivo.net\r\nReply-To: info@inarrivo.net\r\nBcc: info@miafoto.it";
//add boundary string and mime type specification
$headers .= "\r\nContent-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\"";
//define the body of the message.
//Turn on output buffering
ob_start(); //Turn on output buffering
?>
--PHP-alt-<?php echo $random_hash; ?> 
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

<? echo $contentPlain; ?>

--PHP-alt-<?php echo $random_hash; ?> 
Content-Type: text/html; charset="iso-8859-1"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

<? echo "<a href=\"http://www.inarrivo.net\"><img border=\"0\" src=\"http://www.miafoto.it/iPhone/inarrivo/inarrivo.png\" width=\"640\" height=\"363\" alt=\"In Arrivo! for iPhone/iPad - Easier Travel by Bus in Rome\"></a><p>".
$contentHtml; ?>

--PHP-alt-<?php echo $random_hash; ?>--
<?
//copy current buffer contents into $message variable and delete current output buffer
$message = ob_get_clean();
$headers .= 'Bcc: fbartolom@gmail.com' . "\r\n";
//send the email
$mail_sent = @mail( $to, $subject, $message, $headers );


What might be wrong?
fbartolom
New php-forum User
New php-forum User
 
Posts: 17
Joined: Sun Apr 01, 2012 11:52 pm

Return to PHP coding => Mail

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.