dimanche 16 octobre 2022

Weird error when trying to send MAIL Laravel. Address in mailbox given [] does not comply with RFC 2822, 3.6.2

So i'm trying to send an email to a fixed email address

Here is the code :

        //This piece of code is executed when i press a button inside an HTML form
        $announcement = $request->input("announcement");     //This comes from an HTML text input
        $subject = "Hello this is the title of the email";
        $data = [
                'email_body' => "This is the body of the email where the message is displayed : <br><br>".$announcement
        ];

        Mail::send('emails.email_view', $data, function ($message) use ($subject) {
                $message->from(env("MAIL_FROM_ADDRESS"), 'Some name');
                $message->to("validEmail@gmail.com")->subject($subject);
        });

When this piece of code is executed it shows me the error mentioned in the title :

Address in mailbox given [] does not comply with RFC 2822, 3.6.2.

The thing is when i refresh the page(url) where the error is displayed it obviously prompts me to Confirm Form Resubmission and when i confirm, the code is executed without a problem , sending the email as it is supposed to do in the first place.

I've tried storing the email in a variable and using trim() or str_replace() to clear the string from possible whitespace, i've tried sending it inside the to() function as an array as mentioned in a question about the same problem still no luck.

Also the code 1 out of 40 tries doesn't display the error and works as supposed to work.

Im' using laravel 5.5

I'm so lost what should i do, where should i look ?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire