限制Laravel中的电子邮件流量 [英] Limit e-mail flow in Laravel

查看:104
本文介绍了限制Laravel中的电子邮件流量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Laravel 4.2构建的应用程序.

I'm working on an app built with Laravel 4.2.

我的应用程序将发送大量单独的电子邮件.问题是我的SMTP服务器的上限是每30分钟300封邮件和每天5000封邮件

My app will send a pretty large amount of individual emails. The problem is that my SMTP server has a limit of max 300 mails/30 minutes and 5000 mails/day

对我来说这就足够了.但是我想通过将它们排队以最大300邮件/30分钟的速率发送来控制sen电子邮件的流量.

That will be enough for me. But I would want to control the flow of sen email by queuing them up to be sent at a rate of max 300 mails/30 mins.

使用Laravels库是否有一种简单的方法?

Is there a simple way of doing that, using Laravels libraries?

推荐答案

您在队列的正确位置.假设您有一个数据库表,其中每个要发送的电子邮件都有一行,并且有一个跟踪该电子邮件是否已发送的列.您可以创建一个Laravel 命令,该命令每30分钟执行一次cronjob,然后发送下一个300封尚未发送的电子邮件.

You're on the right track with the queue. Say you had a DB table with one row for each email to be sent, and a column tracking if that email has been sent. You could create a Laravel Command that would be executed as a cronjob every 30 minutes that would send the next 300 emails that have not yet been sent.

一个更好,更清洁,更可扩展的选择是实现Laravel 队列.这将需要修改服务器环境,就像安装mysql来支持数据库一样.

A better, cleaner and all around more scaleable option would be to implement one of the many queue engines supported by Laravel's Queues. This will require modification of the server environment much like installing mysql to support the database.

这篇关于限制Laravel中的电子邮件流量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆