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 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题