如果用戶標記問題,如何通過jQuery和PHP發送電子郵件?通過jQuery/PHP發送電子郵件
我的頭JS代碼
jQuery('a.flag_question').live('click', function(){
jQuery.post('/codes/handlers/flag_question.php',
{ question_id: jQuery(this).attr('rel') });
alert ("Question was reported.");
});
其處理程序flag_question.php不給我一個電子郵件
$question_id = $_POST['question_id']; // data from jQuery.post
$subject = "Flagged question";
$to = '"Michael Boltman <[email protected]>';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$message = "<a href='index.php?question_id=" . $question_id . "'>"
. "The question " . $question_id . "</a> is flagged by an user. Please, review it.";
if (mail($to, $subject, $message)) {
echo ("Thank you for your report!");
}
我也用我的真實電子郵件地址,而代碼中的一個是僞代碼。
鏈接是由PHP
echo ("<a href='#'"
. " class='flag_question'"
. " rel='" . $question_id . "'>flag</a>"
);
我在我的電腦上使用本地主機。 **如何設置郵件服務器?** – 2009-08-23 17:44:16
這對於Ubuntu:https://help.ubuntu.com/community/MailServer 而這個適用於windows:http://www.hmailserver.com/ A可用電子郵件服務器的完整列表如下:http://en.wikipedia.org/wiki/Comparison_of_mail_servers – 2009-08-24 09:37:26