我使用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
tenho:
<?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
]);
}
}
我已经多次重读文档和我的代码,但没有发现任何错误
它有什么用?
答案 0 :(得分:1)
可能有多种原因:
php artisan config:cache
)laravel.log
文件)2525
端口同时查看您的代码,似乎您错过了将$input
参数传递给构造函数。你有:
public function __construct($inputs)
但你跑:
->send(new DataManifestationMail());
没有传递任何价值