My .env file is:
MAIL_DRIVER=mail MAIL_HOST=smtp.mandrillapp.com MAIL_PORT=587 MAIL_USERNAME=sabin.maharjan456@gmail.com MAIL_PASSWORD=****************************
Mailer.php
<?php namespace App\Http\Controllers; class Mailer{ public function sendTo($email, $subject, $view, $data = array()) { \Mail::queue($view, $data, function($message) use($email, $subject) { $message->to($email)->subject($subject); }); return "Mail has been sent"; } public function welcome($formData) { $subject = "User Message was arrived !"; $data['name'] = $formData['name']; $data['email'] = $formData['email']; $data['mobile'] = $formData['mobile']; $data['subject'] = $formData['subject']; $data['bodymessage'] = $formData['message']; $view = 'emails.welcome'; return $this->sendTo([' sabin.maharjan456@gmail.com '],$subject,$view,$data); } }
Controller or:
public function postContactFormRequest(CreateContactFormRequest $request,Mailer $mailer) { $formData = $request->all(); $this->mailer->welcome($formData); }
view file:
<!DOCTYPE html> <html lang="en-US"> <head> <meta charset="utf-8"> </head> <body> <h2>User Message</h2> <p><b>Email Address:</b> {{ $email }}</p> <h4>User Name : {{ $name }}</h4> <p> Phone Number :{{ $mobile}}</p> <p>Message :{{ $bodymessage }} </p> </body> </html>
this is my file: I get a continuous error while trying to send an email.
Argument 1 is missing for Illuminate \ Support \ Manager :: createDriver (), is called in / home / robustit / public _html / nic-website / vendor / laravel / framework / src / Illuminate / Support / Manager.php on line 89 and is defined
source share