Laravel mail error: Process could not be started [The system cannot find the path specified. ]

Farkhod Allamuradov picture Farkhod Allamuradov · Dec 15, 2018 · Viewed 19.2k times · Source

I'm developing a new Laravel application. When I'm using mail to send messages via contact form in my website, I'm getting the following error:

Process could not be started [The system cannot find the path specified. ]

I'm developing in my local environment but using my business mail to get messages.

My controller:

namespace App\Http\Controllers;

use App\SendMessage;
use App\Mail\SendEmail;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Mail;
use App\Http\Controllers\Controller;
use Session;

class SendMessageController extends Controller
{
    public function store(Request $request) {
        $this->validate($request, [
            "email" => "required|email",
            "message" => "min:10",
            "subject" => "min:3"
        ]);


        $name = $request->name;
        $email = $request->email;
        $company = $request->company;
        $subject = $request->subject;
        $message = $request->message;

        Mail::to("[email protected]")->send(new SendEmail($subject, $message));

        Session::flash("success", "Your email was sent");

        return back();
    }
}

?>

My mailing function:

<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

class SendEmail extends Mailable
{
    use Queueable, SerializesModels;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public $sub;
    public $mese;
    public function __construct($subject, $message)
    {
        $this->sub = $subject;
        $this->mes = $message;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        $e_subject = $this->sub;
        $e_message = $this->mes;
        return $this->view('emails.contact', compact("e_message"))->subject($e_subject);
    }
}
?>

My .env file:

MAIL_DRIVER=mail
MAIL_HOST=mail.auditors.uz
MAIL_PORT=465
[email protected]
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=tls 

I googled it a lot, but did not find the appropriate answer. If anybody of you can help me, I'll be really happy. Because I've been looking for a solution for a long time.

Answer

Matthijs picture Matthijs · Dec 15, 2018

Your MAIL_DRIVER is set to mail, which does not exist by default. If you are using an SMTP mail server, you should use smtp as the driver.

Please make sure that your email provider supports port 465 and TLS encryption. Most of the providers support these automatically though.