I want to add phpmailer library to magento 2 so for that i followed the following answer What is the simplest way to use an external php library in a custom magento 2 module? and everything works fine on localhost.
But when i tried to run
composer require phpmailer/phpmailer
on server i got the following error
Fatal error : out of memory
I think that this happens because i don’t have enough memories on my server.
So is there an alternative way to add the phpmailer library to magento2 without using composer ?
2
Answers
Actually I found a solution for this problem :
1- add the phpmailer library folder in a directory whithin the custom module folder
2- add the following in the block file
and use $mail = new PHPMailer();
for more info https://github.com/PHPMailer/PHPMailer#installation--loading
You can set memory_limit to carry out composer with the help of the following command: