Jump to content

Problem with Multipart emails


kristenju

Recommended Posts

Hi

 

I have found the code on a forum, it works, but for some reason, when I use to only use HTML to send the email, Google can display it in HTML. But after I have changed it to Multipart (because some of us receives them on blackberry..), it only shows the Plain Text ones even if it's Google.. Please tell me why it is like that...

 

Thanks


// plain text here
$feedback1 = '';
foreach($_POST['comments'] as $k=>$v) {
$feedback1 .= "*";
    $feedback1 .= $_POST['comp'][$k] ."*\r\n";
    $feedback1 .= "- Achalandage: " . $_POST['traffic_' . $k] ."\r\n";
    $feedback1 .= "- Promo: " . $_POST["promo"][$k] ."\r\n";
    $feedback1 .= "- Remarques: " . $_POST["comments"][$k] ."\r\n\r\n";

}

$mes = "Date: " . $inputdate ."\r\n";
$mes .= "Boutique: " . $store ."\r\n";
$mes .= "Responsable: " . $name ."\r\n";
$mes .= "\r\n";
$mes .= "*Productivité de la journée*\r\n";
$mes .= "Ventes / Objectif: " . $day ."\r\n";
$mes .= "Last Year: " . $ly ."\r\n";
$mes .= "Ventes / Objectif (sem.): " . $week ."\r\n";
$mes .= "AST: " . $ast ."\r\n";
$mes .= "AUT: " . $aut ."\r\n";
$mes .= "\r\n";
$mes .= "*Analyse du centre commercial*\r\n";
$mes .= "Achalandage: " . $mall ."\r\n";
$mes .= "Évènements spéciaux:" . $event ."\r\n";
$mes .= "\r\n";
$mes .= "*Analyse de la boutique*\r\n";
$mes .= "Achalandage: " . $boutique ."\r\n";
$mes .= "Type de clientèle: " . $client ."\r\n";
$mes .= "Comportement: " . $attitude ."\r\n";
$mes .= "Styles populaires (2): " . $style ."\r\n";
$mes .= "Problèmes à reporter: " . $problem ."\r\n";
$mes .= "\r\n";
$mes .= "*Analyse de la compétition*\r\n";
$mes .= "\r\n";
$mes .= $feedback1;


// html text here
$feedback = '';
foreach($_POST['comments'] as $k=>$v) {
$feedback .= '<strong>'. $_POST['comp'][$k] .'</strong'>"\r\n";
    $feedback .= "<br>";
$feedback .= "Achalandage: " . $_POST['traffic_' . $k] ."\r\n";
    $feedback .= "<br>";
$feedback .= "Promo: " . $_POST["promo"][$k] ."\r\n";
    $feedback .= "<br>";
    $feedback .= "Remarques: " . $_POST["comments"][$k] ."\r\n\r\n";
    $feedback .= "<br><br>";

}

$html = "<body>";
$html .= "<b>Date: " . $inputdate ."</b><br>";
$html .= "<b>Boutique: " . $store ."</b><br>";
$html .= "<b>Responsable: " . $name ."</b><br>";
$html .= "<br>";
$html .= "<font color=CC333><b>Productivité de la journée</b></font><br>";
$html .= "Ventes / Objectif: " . $day ."<br>";
$html .= "Last Year: " . $ly ."<br>";
$html .= "Ventes / Objectif (sem.): " . $week ."<br>";
$html .= "AST: " . $ast ."<br>";
$html .= "AUT: " . $aut ."<br>";
$html .= "<br>";
$html .= "<font color=CC3333><b>Analyse du centre commercial</b></font><br>";
$html .= "Achalandage: " . $mall ."<br>";
$html .= "Évènements spéciaux: " . $event ."<br>";
$html .= "<br>";
$html .= "<font color=CC3333><b>Analyse de la boutique</b></font><br>";
$html .= "Achalandage: " . $boutique ."<br>";
$html .= "Type de clientèle: " . $client ."<br>";
$html .= "Comportement: " . $attitude ."<br>";
$html .= "Styles populaires (2): " . $style ."<br>";
$html .= "Problèmes à reporter: " . $problem ."<br>";
$html .= "<br>";
$html .= "<font color=CC3333><b>Analyse de la compétition<br></b>";
$html .= $feedback;
$html .= "</body></html>";


// Multipart-Alternative boundary
$message =
'--' . $Email_boundary . "\r\n" .
'Content-Type: text/plain;
charset="utf-8"' . "\r\n" .
'Content-Transfer-Encoding: 8bit' .
"\r\n" .
"\r\n" .
$mes ."\r\n" .
"\r\n" .
"\r\n" .

'--' . $Email_boundary . "\r\n" .
'Content-Type: text/html;
charset="utf-8"' . "\r\n" .
'Content-Transfer-Encoding: 8bit' .
"\r\n" .
"\r\n" .
$html ."\r\n" .
"\r\n" .
"\r\n";

// Copy boundary
$message2 =
'--' . $Copy_boundary . "\r\n" .
'Content-Type: text/plain;
charset="iso-8859-1"' . "\r\n" .
'Content-Transfer-Encoding: 7bit' .
"\r\n" .
"\r\n" .
$mes2 ."\r\n" .
"\r\n" .
$mes ."\r\n" .
"\r\n" .

'--' . $Copy_boundary . "\r\n" .
'Content-Type: text/html;
charset="iso-8859-1"' . "\r\n" .
'Content-Transfer-Encoding: 7bit' .
"\r\n" .
"\r\n" .
$html2 ."\r\n" .
"\r\n" .
"\r\n";

// Header Head Office
$to = "[email protected],[email protected]";
$subject = "Rapport Journalier: $inputdate";
$Email_boundary = "EmailBoundary.".md5(time());

$headers = "From: $store <$storemail>" . "\r\n" .
           "Reply-To: $storemail" . "\r\n" .
           'X-Mailer: PHP/' . phpversion() . "\r\n" .
           "MIME-Version: 1.0";
           'Content-Type: multipart/alternative; boundary=' . $Email_boundary . "\r\n";

// Header Copy to Store
$subject2 = "Copie du Rapport Journalier: $inputdate";
$Copy_boundary = "CopyBoundary.".md5(time());

$headers2 = "From: [email protected]" . "\r\n" .
            'X-Mailer: PHP/' . phpversion() . "\r\n" .
            "MIME-Version: 1.0";
            'Content-Type: multipart/alternative; boundary=' . $Copy_boundary . "\r\n";


// Send emails
mail($to, $subject, $mes, $headers);
mail($storemail, $subject2, $mes2, $headers2);

 

Link to comment
https://forums.phpfreaks.com/topic/176486-problem-with-multipart-emails/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.