Google Gmail SMTP

Posted 2 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.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.