0

I am very new to PHP/LARAVEL development trying to develop 1 application to send the email from smtp.gmail.com.

I am getting error as

[ [Tue Jan 11 17:11:32.765352 2022] [php:error] [pid 21752:tid 1952] [client ::1:56549] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 132124672 bytes) ]

in below line of code:

try {
      Mail::to($user->email)->send(new SendMail($message1,$notification_template->subject));
} 
catch (\Throwable $th) {
      throw $th;
}

I already tried to set memory_limit to -1(no limit) or 2048M in php.ini, but no luck. Getting same error from XAMPP and VSCode.

I am using gmail as SMTP server for sending email.

Can you please help me to understand the issue and to fix it?

user3783243
  • 5,368
  • 5
  • 22
  • 41
Abhi
  • 1
  • Is this in a loop? You're too minimal here for us to help, likely issue is elsewhere. – user3783243 Jan 11 '22 at 13:32
  • This is not in loop. But when i comment //throw $th, it redirect the users to desired page although mail is not sent (sendmail block might be sending in catch block). When i uncomment throw $th, this prints the error in log and throws the exception. – Abhi Jan 11 '22 at 13:42
  • Why are you throwing something that you just caught? The best thing to do in that section is to log what the issue is, and return a message to the user. – aynber Jan 11 '22 at 13:48
  • When you changed the memory limit, did you restart the PHP process? – Chris Haas Jan 11 '22 at 14:13

1 Answers1

0

change in following file this will solve your problem:

File: /etc/php.ini

memory_limit = 512M;