【发布时间】:2013-11-25 06:59:51
【问题描述】:
我有一个功能,可以根据在 oscommerce 中购买的产品数量发送多封电子邮件。在我为函数的 php mail() 部分添加标题之前,它工作得很好。正如你在下面看到的,我的标题是:
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: info@email.com \r\n" .
"Reply-To: info@email.com \r\n" .
"X-Mailer: PHP/" . phpversion();
但是当我声明标题(我需要它以将电子邮件作为 html 发送)时,只发送第一封电子邮件。我不能多次发送标头吗?任何建议将不胜感激!
函数sn-p:
foreach ($dstToProduct as $dsid => $productIndices) {
$email = $newDropships[$dsid]['email'];
$subject = "A new order has been placed";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: info@email.com \r\n" .
"Reply-To: info@email.com \r\n" .
"X-Mailer: PHP/" . phpversion();
// Build message text
$date = date('m/d/Y');
$text = '<table cellpadding="3" style="margin-top: 20px;"><tr style="background-color: #6d7d59; color: #ffffff; font-weight: bold; font-size: 12px;"><td style="width: 240px; vertical-align:text-top;">Product Name</td><td style="width: 120px; vertical-align:text-top;">Model Number</td><td style="width: 80px; vertical-align:text-top;">Quantity</td><td style="width: 80px; vertical-align:text-top;">Price</td></tr>';
foreach ($productIndices as $productIndex) {
$text .= '<tr style="background-color: #f0f0f0; color: #513311; font-size: 12px;"><td style="vertical-align:text-top;">' . $products_array[$productIndex]["text"] . '</td><td style="vertical-align:text-top;">' . $products_array[$productIndex]["model"] . '</td><td style="vertical-align:text-top;">' . $products_array[$productIndex]["qty"] . '</td><td style="vertical-align:text-top;">' . $products_array[$productIndex]["price"] . '</td></tr>';
}
$text .= '</table>';
if (!mail($email, $subject, $text, $headers)) {
mail('info@email.com', 'Error sending product', 'The following order was not sent: ' . $order_id);
}
}
}
【问题讨论】:
-
您收到任何错误(在发送第一封邮件后)?
-
没有错误被抛出,我在错误日志中也找不到任何东西。似乎它只是停止循环
标签: php email content-type oscommerce