我試圖發送一個電子郵件到多個地址,所以我寫了函數,從數據庫中拉電子郵件,並用逗號分隔每個郵件,但郵件部分保持失敗。然而,與getmails()類似的功能正在另一個頁面上工作,所以我真的迷失在我做錯了什麼。這裏是我的代碼,任何幫助將不勝感激。PHP郵件()函數失敗
謝謝大家。
function getmails()
{
$id = mysql_query("SELECT * FROM subscribes ORDER BY subscribe_id DESC") or die(mysql_error());
$elements = array();
while($activeArray=mysql_fetch_array($id))
{
$elements[] = $activeArray['subscribe_email'] ;
}
$main = implode(', ', $elements);
print $main;
}
function announce() {
if(isset($_POST['announce'])) {
$ToEmail = getmails();
$EmailSubject = "".$_POST['title']."";
$mailheader .= "From: [email protected]\r\n";
$mailheader = "Reply-to:".$_POST['author']."@subdomain.domain.com\r\n";
$mailheader = "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY = "Author: ".$_POST['author']."<br>";
$MESSAGE_BODY = "Newsletter: ".$_POST['content']."<br>";
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
}
}
看,這就是爲什麼我喜歡這個地方...有時需要第二隻眼睛才能看到問題..非常感謝您的回答:) – Lea 2009-04-28 12:09:17