因此,当我使用内部 php 应用程序发送电子邮件爆炸时,我的函数会被调用,该应用程序是由多年未在这里工作的程序员为我们的一个客户开发的。
它说“X电子邮件发送成功!”,但我从来没有收到它们。:/
也许我需要更具体地记录错误,因为我找不到导致它的原因。
有人有什么建议吗?
function SendBroadCastEmail() {
ini_set("SMTP", "206.196.112.2" );
ini_set('sendmail_from', 'theagencykc@gmail.com');
$clsPortfolio = new Portfolio();
if ($_REQUEST["frmBroadcastGroup"] == "All") {
$strWhere = "";
}elseif ($_REQUEST["frmBroadcastGroup"] == "Active") {
$strWhere = " WHERE p.Active = 1 ";
}elseif ($_REQUEST["frmBroadcastGroup"] == "Custom") {
$selectEmails = array_unique($_REQUEST['frmBroadcastRecipentList']);
$strWhere = " WHERE ";
foreach ($selectEmails as $intRecipent) {
$strWhere .= " OR Portfolio_ID = '$intRecipent' ";
}
$strWhere = str_replace(" WHERE OR", " WHERE ", $strWhere);
}
$clsPortfolio->GetList($strWhere);
if ($rsRecipients = mysql_fetch_array($clsPortfolio->rsResult)) {
do {
if (trim($rsRecipients["Email"]) == "") {
$aryNoEmail[] = array("Name" => stripslashes($rsRecipients["Name"]), "Portfolio_ID" => $rsRecipients["Portfolio_ID"]) ;
}else{
$aryRecipents[] = $rsRecipients["Email"];
}
} while($rsRecipients = mysql_fetch_array($clsPortfolio->rsResult));
}
$strHeaders = "MIME-Version: 1.0\r\n";
$strHeaders .= "Content-type: text/html; charset=iso-8859-1\r\n";
$strHeaders .= "From: theagencykc@gmail.com\r\n";
foreach ($aryRecipents as $strRecipient) {
mail(stripslashes($strRecipient), stripslashes($_REQUEST["frmBroadcastSubject"]),stripslashes( $_REQUEST["frmBroadcastBody"]), $strHeaders);
if (mail(stripslashes($strRecipient), stripslashes($_REQUEST["frmBroadcastSubject"]),stripslashes( $_REQUEST["frmBroadcastBody"]), $strHeaders)) {
echo("<p>Message successfully sent, buddy!</p>");
} else {
echo("<p>Message delivery failed... buddy</p>");
}
}
$strBroadcastResults = "<b>" . count($aryRecipents) . " Emails Sent Successfully<br>";
if (count($aryNoEmail) > 0) {
$strBroadcastResults .= "<u>The following models had no email on file:</u><br>";
foreach ($aryNoEmail as $aryIndividual) {
$strBroadcastResults .= "<a href=\"/docs/edit_portfolio.php?model_id=$aryIndividual[Portfolio_ID]\" target=\"_blank\">$aryIndividual[Name]</a> ,";
}
}
return $strBroadcastResults;
}