我需要为我的项目发送消息(电子邮件/电报/短信等)分发。 它需要分成每个用户列表(新帐户,付费帐户,付费等)和发送提供商(电子邮件,电报......)
是否有任何开源或付费解决方案? (perefer laravel或者只是php,但它并不重要)
你如何在项目中解决它?
答案 0 :(得分:0)
回答你的问题:
我会清楚地使用Laravel Notifications,因为你说你喜欢,Laravel,php和开源一体化。有许多驱动程序,包括您提到的驱动程序,您可以检查它们here。
关于如何将其集成到用户组中,您需要使用特征通知:
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Notifiable;
}
然后您只需要创建您感兴趣的用户集合,并使用Facade向他们发送通知:
Notification::send($users, new InvoicePaid($invoice));
作为额外的建议,我建议您设置队列并排队这些通知,因为您的用户组可能很大:
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
class InvoicePaid extends Notification implements ShouldQueue
{
use Queueable;
// ...
}
希望这会对你有所帮助。