Php laravel无法发送电子邮件,这不是错误

Php laravel无法发送电子邮件,这不是错误,php,laravel,email,smtp,formbuilder,Php,Laravel,Email,Smtp,Formbuilder,我已经做了一个项目一个月,真的很困惑为什么我没有收到电子邮件,我按照教程,并尝试在其他项目没有任何错误,我收到了电子邮件,但我与我的项目合并后,我没有收到电子邮件 这是我的配置 /* |-------------------------------------------------------------------------- | Mail Driver |-------------------------------------------------------------------

我已经做了一个项目一个月,真的很困惑为什么我没有收到电子邮件,我按照教程,并尝试在其他项目没有任何错误,我收到了电子邮件,但我与我的项目合并后,我没有收到电子邮件

这是我的配置

/*
|--------------------------------------------------------------------------
| Mail Driver
|--------------------------------------------------------------------------
|
| Laravel supports both SMTP and PHP's "mail" function as drivers for the
| sending of e-mail. You may specify which one you're using throughout
| your application here. By default, Laravel is setup for SMTP mail.
|
| Supported: "smtp", "sendmail", "mailgun", "mandrill", "ses",
|            "sparkpost", "postmark", "log", "array"
|
*/

'driver' => env('MAIL_DRIVER', 'smtp'),

/*
|--------------------------------------------------------------------------
| SMTP Host Address
|--------------------------------------------------------------------------
|
| Here you may provide the host address of the SMTP server used by your
| applications. A default option is provided that is compatible with
| the Mailgun mail service which will provide reliable deliveries.
|
*/

'host' => env('MAIL_HOST', 'smtp.mailgun.org'),

/*
|--------------------------------------------------------------------------
| SMTP Host Port
|--------------------------------------------------------------------------
|
| This is the SMTP port used by your application to deliver e-mails to
| users of the application. Like the host we have set this value to
| stay compatible with the Mailgun e-mail application by default.
|
*/

'port' => env('MAIL_PORT', 587),

/*
|--------------------------------------------------------------------------
| Global "From" Address
|--------------------------------------------------------------------------
|
| You may wish for all e-mails sent by your application to be sent from
| the same address. Here, you may specify a name and address that is
| used globally for all e-mails that are sent by your application.
|
*/

'from' => [
    'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
    'name' => env('MAIL_FROM_NAME', 'Example'),
],

/*
|--------------------------------------------------------------------------
| E-Mail Encryption Protocol
|--------------------------------------------------------------------------
|
| Here you may specify the encryption protocol that should be used when
| the application send e-mail messages. A sensible default using the
| transport layer security protocol should provide great security.
|
*/

'encryption' => env('MAIL_ENCRYPTION', 'tls'),

/*
|--------------------------------------------------------------------------
| SMTP Server Username
|--------------------------------------------------------------------------
|
| If your SMTP server requires a username for authentication, you should
| set it here. This will get used to authenticate with your server on
| connection. You may also set the "password" value below this one.
|
*/

'username' => env('MAIL_USERNAME'),

'password' => env('MAIL_PASSWORD'),

/*
|--------------------------------------------------------------------------
| Sendmail System Path
|--------------------------------------------------------------------------
|
| When using the "sendmail" driver to send e-mails, we will need to know
| the path to where Sendmail lives on this server. A default path has
| been provided here, which will work well on most of your systems.
|
*/

'sendmail' => '/usr/sbin/sendmail -bs',

/*
|--------------------------------------------------------------------------
| Markdown Mail Settings
|--------------------------------------------------------------------------
|
| If you are using Markdown based email rendering, you may configure your
| theme and component paths here, allowing you to customize the design
| of the emails. Or, you may simply stick with the Laravel defaults!
|
*/

'markdown' => [
    'theme' => 'default',

    'paths' => [
        resource_path('views/vendor/mail'),
    ],
],

/*
|--------------------------------------------------------------------------
| Log Channel
|--------------------------------------------------------------------------
|
| If you are using the "log" driver, you may specify the logging channel
| if you prefer to keep mail messages separate from other log entries
| for simpler reading. Otherwise, the default channel will be used.
|
*/

'log_channel' => env('MAIL_LOG_CHANNEL'),
这是我的应用程序/邮件。观点是正确的

use Queueable, SerializesModels;

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

/**
 * Build the message.
 *
 * @return $this
 */
public function build()
{
    return $this->subject('Mail from Admin')
        ->view('email.sendmail');
}
这是我的控制器,已添加“使用App\email\u atasan”

    $form = Form::where('identifier', $identifier)->firstOrFail();
    DB::beginTransaction();

    try {
        $input = $request->except('_token');

        // check if files were uploaded and process them
        $uploadedFiles = $request->allFiles();
        foreach ($uploadedFiles as $key => $file) {
            // store the file and set it's path to the value of the key holding it
            if ($file->isValid()) {
                $input[$key] = $file->store('fb_uploads', 'public');
                $details = [
                    'title' => 'Name',
                    'body' => 'Please check this link'
                ];

                \Mail::to('myemail@domain')->send(new email_atasan($details));
            }

        }

        $user_id = auth()->user()->id ?? null;
        $form->submissions()->create([
            'user_id' => $user_id,
            'status' => 0,
            'content' => $input,
        ]);
        DB::commit();

        return redirect()
                ->route('formbuilder::form.feedback', $identifier)
                ->with('success', 'Form successfully submitted. Please wait');
    } catch (Throwable $e) {
        info($e);

        DB::rollback();

        return back()->withInput()->with('error', Helper::wtf());
    }


请帮帮我

听起来你并不是在“处理队列”,请确保在终端中运行
php artisan queue:work
,或
php artisan queue:listen
(如果你经常更改代码)。

检查以下解决方案:

1.您的电子邮件配置:检查您的电子邮件是否
不太安全
不是两步
登录
,最好在浏览器中的一个选项卡中打开

2.你说的对吗?也许你的路线错了


3.你是否使用
队列
事件
?如果答案是肯定的,那么检查你是否
解雇他们??

大家好,谢谢你们的回答,我发现了问题。未阅读详细信息,因此我应该在App\mail中声明

 public function build()
    {
        $detail=$this->details;
        return $this->subject('Mail from Admin BPPT')
            ->view('email.sendmail', compact('detail'));
    }

我在搜索“laravel mandrill无错误无电子邮件”时遇到了这个问题

这似乎很明显,但如果您的config/mail.php中没有配置发件人地址,则Mandrill将拒绝邮件,并且不会发送,但不会抛出错误,从而允许/鼓励Laravel告诉您

你会期待一个“Mandrill拒绝了你的邮件-没有来自地址”,你会去doh我忘了设置它。在我的情况下,我的报名表是有效的——我们给你发了一封验证电子邮件——但它没有


希望这对其他人有所帮助。

要确定错误的来源,您可以直接从路由文件发送一封简单的电子邮件。例如:
Route::get('test',function(){\Mail::to('test')myemail@domain“)->发送(新电子邮件_atasan(['title'=>'aa','body'=>'bb']);})(不要忘记导入)您可以直接调用此路由,以确保您的代码真正执行并查看发生了什么。另外,检查
QUEUE\u连接的
env值,为测试尝试将其值设置为“sync”。