クライアントに awstats レポートを送信するために、月に 1 回 cron ジョブを介して実行されるこのスクリプトがあります。送信メール サーバーの制限が厳しくなったため、最近変更する必要がありました。残念ながら、一部の受信者は、レポートをメッセージの本文に生の 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);
ここでは明らかに変数宣言を省いています。しかし、それらはすべてコード内にあります。私は実際にメッセージの cc を受け取り、デスクトップの Apple Mail に問題なく表示されます。
ありがとう、CJ