6

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("audit@auditors.uz")->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
MAIL_USERNAME=audit@auditors.uz
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.

Matthijs
  • 2,483
  • 5
  • 22
  • 33

2 Answers2

12

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.

Matthijs
  • 2,483
  • 5
  • 22
  • 33
  • I've solved previous problem with your help. But now I'm taking the error: Swift_TransportException thrown with message "Expected response code 220 but got an empty response" – Farkhod Allamuradov Dec 15 '18 at 10:21
  • Do you have any idea? – Farkhod Allamuradov Dec 15 '18 at 10:22
  • I think this answer is able to help you: https://stackoverflow.com/a/32696418/3625118 If my answer solved your issue, please accept it, so other visitors are able to find a solution easier :-) – Matthijs Dec 15 '18 at 10:28
0

Use MAIL_DRIVER="smtp"

Do not forget to Re-Serve or clear cache of Laravel [ php artisan optimize:clear / php artisan config:clear / php artisan cache:clear ]

Dennis Richter
  • 522
  • 6
  • 16
Meet
  • 42
  • 3