Twittler's avatar

Laravel Mail does not send to mailtrap

Hi guys, i'm having trouble sending mail i'm using mailtrap. Page redirects without errors and do not send mail, sometimes it says "Process could not be started [The system cannot find the path specified. ]" i have tried using mail_driver = mail but that do not work.

.env

MAIL_DRIVER=smtp

MAIL_HOST=smtp.mailtrap.io

MAIL_PORT=2525

MAIL_USERNAME=ffc415fa96e9b8

MAIL_PASSWORD=4c04fc5918df03

MAIL_ENCRYPTION= tls

Controller public function PostContact(Request $request) {

  $data = array(
    'email' => $request -> email,
    'subject' => $request -> subject,
    'bodyMessage' => $request -> message
  );

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

  Session::flash('success', 'Your Email was sent!');

  return redirect() -> back();

}

Thanks!

0 likes
14 replies
arthvrian's avatar

question

did you are checking YOUR email account or your MAILTRAP account?

arthvrian's avatar

is your .env config equal to the config shows in mailtrap?

BillRiess's avatar

You'll want to install postfix if its not installed. There are plenty of guides out there but you can get started with sudo apt install postfix.

arthvrian's avatar

Ok, your config is OK (.env and config/mail.php)

are you trying this from Windows or Linux (localhost)? or in a test server (i.e DO)?

localhost many times does not have sendmail (as said @billriess) in windows did not exists you must install other tools (i don't remember the name); in linux you can run the command wrote by @billriess

BillRiess's avatar

Try running your code in Homestead or Valet (if you're using a Mac) and see if you have the same issue. This should isolate the problem down to a missing system dependency or a code-related issue.

ekpono's avatar

Check your log for the error message and also make sure u have internet connection

Twittler's avatar

Thanks guys for the help, i will try to upload website to host. :)

Please or to participate in this conversation.