Whenever I use AddEmbeddedImage
in PHPMailer
, I get this error:
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
This is line 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. I also looked at threads about using AddEmbeddedImage()
, but none of the questions say anything about the error, and the syntax is correct.
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
Fatal error: Maximum execution time of 30 seconds exceeded in C:\\xampp\\htdocs\\amac2017\\phpmailer\\class.smtp.php on line 999
Line 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. It is permissible to adjust the configuration file of PHP as needed. Maybe you can narrow your picture and adjust the php.ini appropriately.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.