我有一個腳本每月運行一次cron作業,向客戶發送awstats報告。我們最近不得不修改它,因爲我們的出站郵件服務器收緊了限制。不幸的是,一些收件人在郵件正文中以原始html代碼的形式接收報告。任何人都可以從劇本中知道我出錯的地方嗎?電子郵件腳本格式不正確
##########################
## Call to get awstats
##########################
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL,"http://www.$your_domain:2082/awstats.pl"
."?month=$report_month&year=$report_year&output=main&config=$your_domain"
."&lang=en&framename=mainright");
curl_setopt($curl, CURLOPT_USERPWD, "$user:$password");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
//$attachment = curl_exec($curl);
$attachment = "<br /><br /><div align=\"center\"><a href=\"$logo_link\"><img src=\"$logo_path\" border=\"0\" /></a>\n";
$attachment .= "<br /><font color=\"#FF0000\"><b>AwStats Report for $your_domain ($report_monthname $report_year)</b></font></div>\n";
$attachment .= "<base href=\"$awstats_img_path\">\n";
$attachment .= curl_exec($curl);
curl_close($curl);
##########################
## Call to send email
##########################
$subject = "AwStats Report for $your_domain ($report_monthname $report_year)";
$header = "From: " . $email_from . " <" . $email_from . ">\n";
$header .= "Reply-To: " . $email_from . "\n";
$header .= "MIME-Version: 1.0\n";
$header .= "Content-Type: multipart/mixed; boundary=\"" . $uid . "\"\n\n";
$uid = md5(uniqid(time()));
$message = "--" . $uid . "\n";
$message .= "Content-type:text/html; charset=iso-8859-1\n";
$message .= "Content-Transfer-Encoding: 7bit\n\n";
$message .= $attachment . "\n\n";
mail($email_to, $subject, $message, $header);
我明顯地忽略了這裏的變量聲明。但他們都在代碼中。我實際上收到了一條消息,並且它在桌面上的Apple Mail中顯示得很好。
感謝, CJ
哪裏?在前景? – devpro
客戶端可能正在使用outlook。我正在使用Mac Mail。 –