Laravel 邮件错误:进程无法启动 [系统找不到指定的路径。]

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/53790556/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 18:13:00  来源:igfitidea点击:

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

laravellaravel-mail

提问by Farkhod Allamuradov

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:

我正在开发一个新的 Laravel 应用程序。当我使用邮件通过我网站中的联系表单发送消息时,出现以下错误:

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 .envfile:

我的.env文件:

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.

我用谷歌搜索了很多,但没有找到合适的答案。如果你们中有人能帮助我,我会很高兴。因为我一直在寻找解决方案。

回答by Matthijs

Your MAIL_DRIVERis set to mail, which does not exist by default. If you are using an SMTP mail server, you should use smtpas the driver.

MAIL_DRIVER的设置为mail,默认情况下不存在。如果您使用的是 SMTP 邮件服务器,则应将其smtp用作驱动程序。

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

请确保您的电子邮件提供商支持端口 465 和 TLS 加密。不过,大多数提供商会自动支持这些。