在我的laravel项目后端,我需要跟踪批量邮箱打开,点击,反弹等我使用像素图像来跟踪邮件.当发送邮箱通常使用循环跟踪工作正常.但是当使用cron调度发送邮件时,邮件打开跟踪不起作用.有什么问题?
我的控制器:
Mail::to($this->email)->send(new MarketingMail($this->subject,$this->template,$this->id, $this->email, $this->file_urls ? $this->file_urls : ''));
Mailable类中的代码:
class MarketingMail extends Mailable
{
use Queueable, SerializesModels;
/**
* Get the message envelope.
*/
public $subject;
public $template;
public $id;
public $email;
public $file_url;
/**
* Create a new message instance.
*/
public function __construct($subject,$template,$id, $email, $file_url)
{
$this->subject = $subject;
$this->template = $template;
$this->id = $id;
$this->email = $email;
$this->file_url = $file_url;
}
/**
* Get the message envelope.
*/
public function envelope(): Envelope
{
return new Envelope(
subject: $this->subject,
);
}
/**
* Get the message content definition.
*/
public function content(): Content
{
return new Content(
view: 'mail.mail',
with: ['template' => $this->template, 'id' => $this->id],
);
}
/**
* Get the attachments for the message.
*
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
*/
public function attachments()
{
if ($this->file_url) {
foreach ($this->file_url as $file) {
$this->attach(public_path($file));
}
}
}
}
Blade 文件:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<img src="{{ route('track_open',[$id]) }}" />
{!! $template !!}
</body>
</html>
正常发送邮件时,跟踪工作正常.但是当使用cron进行调度时,跟踪是不起作用的.什么原因?