isSMTP(); $mail->SMTPKeepAlive = true; $mail->SMTPDebug = false; $mail->Timeout = 20; // Set mailer to use SMTP $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = 'Email Address here'; // SMTP username $mail->Password = 'Password Here'; // SMTP password $mail->SMTPSecure = "ssl"; // Enable TLS encryption, `ssl` also accepted $mail->Port = 465; // TCP port to connect to $mail->setFrom('Email Address here', 'Mobifin'); $mail->addAddress($recepient['email'], $recepient['name']); $mail->isHTML(true); // Set email format to HTML $mail->Subject = $subject; $mail->Body = $email_body; if(!$mail->send()) { $email_error = $mail->ErrorInfo; return [ 'status' => FALSE, 'message' => $email_error ]; } else { return true; } $mail->SmtpClose(); } catch (\Exception $e) { return [ 'status' => FALSE, 'message' => $e->getMessage() ]; } } public function test_mail() { $recepient['name'] = 'test'; $recepient['email'] = 'your email address here'; $subject = 'test larvel'; $message = 'laravel mailer'; $mail_sent = $this->send($recepient, $subject, $message); dd($mail_sent); } public function send_mail(Request $request) { $recepient['name'] = $request->name; $recepient['email'] = $request->email; $subject = 'Contact form'; $message = $request->message; $mail_sent = $this->send($recepient, $subject, $message); return back(); } }