0

用 Laravel 制作了一个 API,它正在正确注册数据

现在我正试图让这个触发注册确认电子邮件,但是这些不会

我正在使用Mailtrap进行测试

.env我这样说:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=291ac7fdcf52bb
MAIL_PASSWORD=610b2e5e9782d3

没有Http/Mail/DataManifestMail.php天豪:

<?php

namespace App\Mail;

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

class DataManifestMail extends Mailable
{
    use Queueable, SerializesModels;

    protected $inputs;

    public function __construct($inputs)
    {
        $this->inputs = $inputs;
    }

    public function build()
    {
        return $this->view('mails.data');
    }
}

views/mails/data.blade.php我只有一条警告信息:

<h1>Test e-mail</h1>

然后在我的Http/Controller/ManifestationController.php我这样说:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Manifestation;
use App\Mail\DataManifestationMail;
use Mail;

class ManifestationController extends Controller
{
    private $manifestation;

    public function __construct(Manifestation $manifestation)
    {
        $this->manifestation = $manifestation;
    }

    public function store(Request $request)
    {
        $nr = Manifestation::max('nrmanifestation');

        $this->manifestation->nrmanifestation = $nr + 1;  
        $this->manifestation->dspass = $request->dspass;
        $this->manifestation->eeemail = $request->eeemail;
        $this->manifestation->address = $request->address;
        $this->manifestation->name = $request->name;
        $this->manifestation->latitude = $request->latitude;
        $this->manifestation->longitude = $request->longitude;

        $this->manifestation->save();

        Mail::to('vazag@c1oramn.com')->send(new DataManifestationMail());

        return response()->json([
            'result' => 
                $this->manifestation->nrmanifestation
            ]);
    }    
}

我已经多次重读文档和代码,没有发现任何错误

会是什么?

4

1 回答 1

1

可能有多种原因:

  • 配置被缓存(使用php artisan config:cache
  • 您使用了无效的邮件陷阱数据(您应该有登录laravel.log文件)
  • 您的服务器以某种方式阻塞了2525端口

还查看您的代码,您似乎错过了将$input参数传递给构造函数。你有:

public function __construct($inputs)

但你运行:

->send(new DataManifestationMail());

不传递任何值

于 2017-12-21T15:39:07.657 回答