Since yesterday I have had problems sending emails with Lumen. I think I have followed all the steps in the documentation correctly, but unfortunately I cannot send anything. Moreover, no error is displayed (I have activated APP_DEBUG=true
), and I am sure that the credentials of the smtp server are correct. I also did composer require illuminate/mail
.
Here are my modifications in bootstrap/app.php (I have $app->withFacades();
uncommented).
Here is my build function content: return $this->view('emails.mailTemplate', ['message' => $this->message]);
.
And the line of code that ask to send mail: Mail::to("wewanthalflifethree@gmail.com")->send(new sendMail($destEmail, $subject, $message));
.
Did I do something wrong? :/
Thx in advance for help!
EDIT: I just noticed something, the code stop working when I send the mail. If I add an echo after Mail::send, it will be appear on the page.
I have a problem with the Exceptions handler. By following this answer (which consists in adding a dd
in the render function of Handler.php
), I am now able to see what's going wrong.
So, here is the reason why my mail didn't send and why my page turned blank: Object of class Illuminate\Mail\Message could not be converted to string (View: /home/serveur-web/api.sl-projects.com/resources/views/emails/mailTemplate.blade.php)
.
The problem came from the fact that I was using the variable name $message
, and this causes problems because it seems to be used in the class that handles the mails. My problem was therefore solved by renaming this variable $mailContent
.
I hope this will help other people. :D