dongxi8993 2016-11-30 09:41
浏览 317

Laravel Mail:如何根据特定域发送批量电子邮件

I am building a newsletter management system using Laravel 5.2.45 which allows the ability for users to send mass emails to mailing lists. As of the moment my example mailing list contains thousands of different email addresses with different email providers such as '@gmail.com', '@hotmail.co.uk'... etc.

When the system is in use, newsletters could potentially be sent to 1000's upon 1000's of different emails, which brings me to ask these few questions.

1) Based on research I believe that it is ideal to minimize the number of connections Laravel opens and closes when sending emails. Meaning, to order the provider domains and send them in batches, so sending all '@gmail.com' in one go so only one connection is open and closed to the gmail server. Is this accurate?

2) If question one is accurate, what would be the best route of doing this using Laravel mail (if the native Laravel mail has the capability of doing so)? I am aware of the ability to use Laravel mail's queue functionality but I am unsure if this would make sure only one connection was open and closed per domain type.

3) Additionally, is the any negative impact of using the Laravel mail class to send newsletters that could potentially go to 20,000 customer emails several times a day?

Thank You,

Kieren.

  • 写回答

1条回答 默认 最新

  • dongtong5242 2016-11-30 09:59
    关注

    Well, depending on how you have configured your mail adaptor – yes, Laravel would open a connection for each e-mail being sent, which is not very efficient if you plan to send that many e-mails.

    I would strongly recommend looking into e-mail providers API:s instead of using a SMTP-connection, most of these offer a batch-functionality. For instance Mailgun: https://documentation.mailgun.com/user_manual.html#batch-sending. Laravel supports the Mailgun-API out of the box.

    Your questions:

    1) Doesn't matter if you batch the emails after the domain like @gmail.com, @yahoo.com or not, if you have a single to-field that's filled out in a for-loop for example, a new connection would be established for each mail over SMTP. The connection is connected to the sending domain, not the receiving one.

    2) I would definitely look into using queues, even if you use Mailguns batch-sending functionality – much more efficient.

    3) Negative impact on what way? Of course, depending on how you build the mail templates, set the e-mail data and what not – it could potentially put a strain on the server. But nothing that can't be built around with some proper programming.

    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘