Google Gmail SMTP

Posted 4 months ago by hjortur17

Hi, I'm trying to use Google Gmail SMTP to receive an ‚Äčemail from my site, but I when I try to send email from the form I get 500 error. Can anybody help me figure this out :)

The .env file:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
[email protected]
MAIL_PASSWORD=MYPASSWORD
MAIL_ENCRYPTION=ssl

The ContactController

public function store(Request $request)
    {
        $this->validate(request(), [
                     'name' => 'required',
                     'email' => 'required|email',
                     'message' => 'required|min:20'
              ]);

              $data = array(
                'name' => request('name'),
                'email' => request('email'),
                'website' => request('website'),
                'bodyMessage' => request('message')
              );

              Mail::send('mails.contact', $data, function ($message) use ($data) {
                $message->from($data['email']);
                $message->to('[email protected]');
                $message->subject('New message from contact form');
              });

        return back()
                     ->with('flash', 'I will here from you soon!');
    }

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.