Laravel Mail::To() 不发送电子邮件但在 Mail::Send() 上工作
Laravel Mail::To() does not send email but works on Mail::Send()
public function sample(){
// USER SUBSCRIPTION
$Subscriber = Subscriber::find(100021);
$email = 'jakeromeopeniano@gmail.com';
Mail::to($email)->send(new Subscribed($Subscriber));
if(Mail::failures()){
return Mail::failures();
}
return 'email sent to ' . $email;
}
我很困惑。我刚刚更换了我的域名托管服务商,现在我的电子邮件出现了问题。但我确信我已经在我的环境中设置了正确的细节。如果我使用 mail::send() 函数,邮件会在 mailgun 中成功发送。但是,如果我使用 mail::to() 函数,我不会收到任何错误,但不会发送电子邮件。我也检查了日志,也没有错误。这是我的代码:
My sample function
<?php
namespace App\Mail;
use App\Subscriber;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class Subscribed extends Mailable implements ShouldQueue
{
use Queueable, SerializesModels;
public $subscriber;
public $password;
public $tries = 2;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct(Subscriber $subscriber, $password = "****")
{
$this->subscriber = $subscriber;
$this->password = $password;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
$subscription = $this->subscriber->subscription;
$subscriber = $this->subscriber;
$password = $this->password;
return $this->markdown('emails.subscription.subscribed', compact('subscriber', 'password'))
->subject($subscription->name . ' subscribed successfully.');
}
}
Subscriber.php
我觉得我很傻,我忘记在ploi中配置我的queue workers了。
public function sample(){
// USER SUBSCRIPTION
$Subscriber = Subscriber::find(100021);
$email = 'jakeromeopeniano@gmail.com';
Mail::to($email)->send(new Subscribed($Subscriber));
if(Mail::failures()){
return Mail::failures();
}
return 'email sent to ' . $email;
}
我很困惑。我刚刚更换了我的域名托管服务商,现在我的电子邮件出现了问题。但我确信我已经在我的环境中设置了正确的细节。如果我使用 mail::send() 函数,邮件会在 mailgun 中成功发送。但是,如果我使用 mail::to() 函数,我不会收到任何错误,但不会发送电子邮件。我也检查了日志,也没有错误。这是我的代码:
My sample function
<?php
namespace App\Mail;
use App\Subscriber;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class Subscribed extends Mailable implements ShouldQueue
{
use Queueable, SerializesModels;
public $subscriber;
public $password;
public $tries = 2;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct(Subscriber $subscriber, $password = "****")
{
$this->subscriber = $subscriber;
$this->password = $password;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
$subscription = $this->subscriber->subscription;
$subscriber = $this->subscriber;
$password = $this->password;
return $this->markdown('emails.subscription.subscribed', compact('subscriber', 'password'))
->subject($subscription->name . ' subscribed successfully.');
}
}
Subscriber.php
我觉得我很傻,我忘记在ploi中配置我的queue workers了。