带邮件的流明-无法解析[Illuminate \ Mail \ TransportManager]的NULL驱动程序

问题描述 投票:1回答:3

我正在尝试从Lumen 5.7发送电子邮件,因此,正如许多消息来源所述,我..

  1. illuminate/mailguzzlehttp/guzzle添加到我的应用程序中
  2. 根据Laravel Repository创建了“ config / mail.php”和“ config / services.php”
  3. 未注释的$app->withFacades();,已注册Illuminate\Mail\MailServiceProvider::class,并在$app->configure('services');中的$app->configure('mail');之前添加了return $app;bootstrap/app.php
  4. 已将Mailgun设置添加到.env

    MAIL_DRIVER = mailgun

    MAILGUN_DOMAIN = ssss

    MAILGUN_SECRET = xxxxx

  5. 试图发送电子邮件Mail::raw('Raw string email', function($msg) { $msg->to(['[email protected]']); $msg->from(['[email protected]']); });

但仍然收到此错误消息Unable to resolve NULL driver for [Illuminate\Mail\TransportManager].

P.S。这是我第一次接触Lumen,我做了很多小时的努力来解决这个问题,但我做不到。

提前感谢。

php email lumen
3个回答
2
投票

如果config文件夹位于“ app”文件夹中,则将“ config”文件夹移至“主文件夹”。这个对我有用。使用来自Laravel(config / mail.php)的邮件基础配置,很抱歉,您的措辞不高[v


1
投票

我也遇到同样的错误,并尝试了许多解决方案,但均未取得积极结果。

我所做的就是用此代码替换config / mail.php,它起作用了。使用流明6.0。

<?php
return [
  "driver" => "smtp",
  "host" => "smtp.mailtrap.io",
  "port" => 2525,
  "from" => array(
      "address" => "[email protected]",
      "name" => "Example"
  ),
  "username" => "user...",
  "password" => "....",
  "sendmail" => "/usr/sbin/sendmail -bs"
];

另外,您可能要考虑的另一件事是确保您的光照/邮件包与laravel / lumen-framework版本匹配。 (以我的情况为6.0)


0
投票

使用Laravel(config/mail.php)中的邮件库配置>

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | 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", "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', '[email protected]'),
        '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'),
        ],
    ],

];

并且不要忘记安装依赖项

composer require guzzlehttp/guzzle
    
© www.soinside.com 2019 - 2024. All rights reserved.