Hello,

I try to send auto mail through laravel using gmail yet getting this error:

Swift_TransportException Connection could not be established with host smtp.gmail.com

.env

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=davy.yg1@gmail.com
MAIL_PASSWORD=*****
MAIL_ENCRYPTION=ssl

MailController.php

 public function SendUndangan(Request $request)
    {

    $title = "Undang Saya";

    $nama = $request->input('nama');
    $telp = $request->input('telp');
    $email = $request->input('email');
    $subject = $request->input('subject');

    Mail::send('email.undangan', ['title' => $title, 'nama' => $nama, 
    'telp' => $telp, 'email' => $email, 'subject' => $subject], function ($message) //use ($attach)
    {

        $message->from('davy.yg1@gmail.com', 'Admin Shaklee');

        $message->to(['davy_yg@yahoo.com']);

        //Add a subject
        $message->subject("Undang Saya");

    });

    return redirect('undang');

}

Any clue why?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.