アート ギャラリーのクライアントがいて、クライアントの小さなメーリング リストがあり、3 週間ごとに 1 つの画像と「登録解除」行だけを含む招待メールを送信しています。クライアントは、画像が添付ファイルとして表示されることも望んでいません。最近一連の問題が発生しており、このタスクが非常に困難になっているため、Web サーバー経由で電子メールを送信するための構造をセットアップしました。画像を含めることができるように、これを行うために Richard Heyes htmlMimeMail パッケージを使用しています。画像は最初に Web サーバーにアップロードされ、各アップロードが前の画像を上書きするように名前が変更されるようにハードコーディングされます。
1 人の受信者と 2 つの Cc に対してテストを実行すると、コードはすべて問題なく動作します。ループ内の構造を使用して約 1500 のクライアントに複数の電子メールを送信すると、突然複数Unknown function implode on line 341
のprereg_match_all()
行エラーが返され、一部 (または多数) の電子メールが送信されません。行とその一部をコメントアウトしてprereg_match_all
エラーを止めるなど、さまざまなことを試しましたが、画像が含まれていないなど、毎回さまざまな問題が発生し、不明な数の電子メールが送信されていないように見えます。
prereg_match_all()
ループのコーディングに問題があるのか、それとも関数コードが問題の根本にあるの かを理解しようとしています。
感謝して受け取ったすべての助け。
これは htmlMimeMail に含まれる変更されていないコードです (私は数年前にライセンスを取得しました)。ところで、共有ホスティングの ISP によって証明された PHP のバージョンの制限により、新しいバージョンを動作させることができず、PHP のさまざまな HTML メール機能も ISP によってコンパイルされていません。
/*
* Function for extracting images from
* html source. This function will look
* through the html code supplied by add_html()
* and find any file that ends in one of the
* extensions defined in $obj->image_types.
* If the file exists it will read it in and
* embed it, (not an attachment).
*
* @author Dan Allen
*/
function _findHtmlImages($images_dir)
{
// Build the list of image extensions
while (list($key,) = each($this->image_types)) {
$extensions[] = $key;
}
preg_match_all('/(?:"|\')([^"\']+\.('.implode('|', $extensions).'))(?:"|\')/Ui', $this->html, $images);
for ($i=0; $i< count($images[1]); $i++) {
if (file_exists($images_dir . $images[1][$i])) {
$html_images[] = $images[1][$i];
$this->html = str_replace($images[1][$i], basename($images[1][$i]), $this->html);
}
}
if (!empty($html_images)) {
// If duplicate images are embedded, they may show up as attachments, so remove them.
$html_images = array_unique($html_images);
sort($html_images);
for ($i=0; $i< count($html_images); $i++) {
if ($image = $this->getFile($images_dir.$html_images[$i])) {
$ext = substr($html_images[$i], strrpos($html_images[$i], '.') + 1);
$content_type = $this->image_types[strtolower($ext)];
$this->addHtmlImage($image, basename($html_images[$i]), $content_type);
}
}
}
}
このループが [電子メールの送信] ページで使用されると、エラーが発生します。
$user
および$useremail
ハードコードされています。$subject
画像アップロードファイルを利用する場合に設定します。$body
および$text
[電子メールの送信] ページで以前に作成されています。
$q=mysql_query("SELECT ``client names`` AND ``email addresses`` FROM ``the database tables`` ORDER BY ``last``");
while($r = mysql_fetch_array($q))
{
$r=stripper($r); //included external function to stripslashes etc
$full=$r['first'].' '.$r['last'];
$em=trim($r['email']);
/* code from htmlMimeMail package */
$mail_1->setHTML($body, $text, '');
$mail_1->setReturnPath("$user <$useremail>");
$mail_1->setFrom("$user <$useremail>");
$mail_1->setSubject("$subject");
$mail_1->send(array("$full <$em>"));
}