0

我有一个艺术画廊客户,他们有一个客户的小型邮件列表,他们每三周发送一封电子邮件邀请,其中仅包含一张图片和一条“取消订阅”行。客户也不希望图像显示为附件。最近出现了一系列问题,这使这项任务非常艰巨,因此我建立了一个结构来通过 Web 服务器发送电子邮件。我正在使用 Richard Heyes htmlMimeMail 包来执行此操作,以便可以包含图像。图像首先上传到 Web 服务器,并经过硬编码以重新命名,以便每次上传都会覆盖之前的图像。

如果我对一个收件人和几个抄送者进行测试,那么代码都可以正常工作。当我在循环中使用该结构向大约 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>"));
}
4

0 回答 0