简体   繁体   English

使用AddEmbeddedImage时发生内存泄漏

[英]Memory leak when using AddEmbeddedImage

Whenever I use AddEmbeddedImage in PHPMailer , I get this error: 每当我在PHPMailer使用AddEmbeddedImage时,都会出现此错误:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 4096 bytes) in C:\\xampp\\htdocs\\project\\phpmailer\\class.smtp.php on line 659 致命错误:659行上的C:\\ xampp \\ htdocs \\ project \\ phpmailer \\ class.smtp.php中的134217728字节已用尽内存大小(尝试分配4096字节)

This is line 659 : 这是659行

$lines = explode("\n", str_replace(array("\r\n", "\r"), "\n", $msg_data));

Here is some part of the code: 这是代码的一部分:

$mail->Body = '
    <html>
        <head>
            <title>Sign-Up Verification</title>
        </head>
        <body style="text-align:center;">
            <img src="cid:letterhead">
        </body>
    </html>
';
$mail->AddEmbeddedImage('img/letterhead.jpg', 'letterhead', 'letterhead.jpg');

The relative path is correct, so I don't think it is the problem. 相对路径是正确的,所以我认为这不是问题。 I already tried using absolute path: 我已经尝试过使用绝对路径:

<img src="C:\xampp\htdocs\project\img\letterhead.jpg"/>

Although the error disappeared, no image is being shown in the mail. 尽管错误消失了,但邮件中没有显示图像。

Threads about the error says that increasing the memory limit should remove it, but I'm trying to avoid editing php.ini just to be safe. 有关该错误的线程说,增加内存限制应将其删除,但是为了安全起见,我试图避免编辑php.ini I also looked at threads about using AddEmbeddedImage() , but none of the questions say anything about the error, and the syntax is correct. 我还查看了有关使用AddEmbeddedImage()线程,但是没有一个问题说明该错误,并且语法正确。

Should I really increase the memory limit? 我真的应该增加内存限制吗? Or is it a localhost problem? 还是本地主机问题?

UPDATE 更新

Tried using a smaller image (1.5mb in size, the original image is 26.7mb) , the error I'm encountering now is 尝试使用较小的图像(大小为1.5mb原始图像为26.7mb) ,我现在遇到的错误是

Fatal error: Maximum execution time of 30 seconds exceeded in C:\\xampp\\htdocs\\amac2017\\phpmailer\\class.smtp.php on line 999 致命错误:第999行的C:\\ xampp \\ htdocs \\ amac2017 \\ phpmailer \\ class.smtp.php中超过30秒的最大执行时间

Line 999 : 999行

$result = fwrite($this->smtp_conn, $data);

PHPMailer::AddEmbeddedImage() is popular to used to add images in the email, so it is unlikely to cause memory leak. PHPMailer::AddEmbeddedImage()很流行用于在电子邮件中添加图像,因此不太可能导致内存泄漏。 It is permissible to adjust the configuration file of PHP as needed. 可以根据需要调整PHP的配置文件。 Maybe you can narrow your picture and adjust the php.ini appropriately. 也许您可以缩小图片范围并适当地调整php.ini。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM