首页 > 解决方案 > 使用 OctoberCMS 进行电子邮件排队

问题描述

任何人都可以提供一些关于如何使用 OctoberCMS ajax 页面排队电子邮件的提示吗?

 function sendRecipientMsg($dataset, $sendCounter, $recipients){
    $template = $dataset['template'];
    Mail::queue($template, $dataset, function($message) use($dataset, $recipients){
        $message->to('piggy@teamprema.co.nz','MissPiggy');
        $message->subject('Have a good day');    
        $message->from('us@prema.co.nz',  'Mike and Stephie');
        $message->sender('us@prema.co.nz',  'Mike and Stephie');

        trace_log('$message');
        $message->cc($address, $name = null);
        $message->bcc('systems@safe.org.nz', 'SAFE Campaigns Feedlots ECards');
    });
 }

此代码在我们使用 Mail::send 但不适用于 Mail::queue 时有效

非常欢迎任何帮助或提示

标签: emailmessage-queueoctobercms

解决方案


在您的config/queue.php文件中,您将哪个驱动程序设置为默认值?

例如:'default' => env('QUEUE_DRIVER', 'sync')

(如果您使用的是DotEnv,请检查.env您的 docroot 中的文件)。

如果您正在使用同步,它应该立即发送,因为同步实际上仅用于开发并且仍然会阻塞。

如果您使用另一种方法,例如数据库,那么您必须确保您的队列配置为按照您的预期处理

尝试运行php artisan queue:work,然后触发您的 ajax 调用,它应该发送。


推荐阅读