如何发送PHP电子邮件多条消息

时间:2015-12-31 06:36:20

标签: php

我们邮件中的输出是 例如:10,20,10,11

我们需要如何获得输出, 喜欢 例如: AA:10, BB:20, CC:10, DD:11,

if(isset($_POST['submit']))
{
 $aa = $_POST['aa'];
 $bb = $_POST['bb'] ;
 $cc = $_POST['cc'] ;
 $dd = $_POST['dd'] ;

 $email = $_POST['email']; 
 $email = explode(',',$email);
 $email = implode(',',$email);

 $subject = 'result';
 // To send HTML mail, the Content-type header must be set
 $headers  = 'MIME-Version: 1.0' . "\r\n";
 $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'From: <sample@sample.co.id>' . "\r\n";
$headers .= 'Cc: ' . "\r\n";
#$headers .= 'Bcc: ' . "\r\n";

#pecah data 
$data = array($aa,$bb,$cc,$dd);
$message = implode(', ', $data) ." <br\>";          

#fungsi email
mail($email,$subject,$message,$headers);
}
?>

1 个答案:

答案 0 :(得分:1)

您可以使用

$message = '';
// Remove email from POST values
unset($_POST['email']);
foreach ($_POST in $field => $value) {
   $message .= strtoupper($field) . ' : ' . $value . '<br />';
}