使用PHP发送大量电子邮件 [英] Sending mass email using PHP

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

问题描述

我正在写一个音乐博客。管理员每2-3天发布一篇新文章。一旦管理员发布文章,大量电子邮件将立即发送给约5000个订阅者。



实现群发邮件功能的最佳方法是什么?



以下功能是否正常工作? p>

  function massmail()
{
$ content ='...'
foreach($ recipient as $ r){
$ _content = $ content。 '< img src =http://xxx/trackOpenRate.php?id ='。$ r。'>';
mail($ r,'subject',$ _content);
}
}

另一个问题:如果所有5000个订阅者都使用Yahoo Mail雅虎会将其视为DDOS攻击并阻止我的SMTP服务器的IP地址?

解决方案

首先,使用邮件()函数不是PHP的最佳解决方案。它很容易被标记为垃圾邮件,您需要设置标题,以确保正确发送HTML电子邮件。至于代码片段是否可以正常工作,但是我怀疑你会得到正确的HTML代码,而没有指定额外的标题



我建议你看一下 SwiftMailer ,它具有HTML支持,支持不同的MIME类型和SMTP身份验证(这不太可能将邮件标记为垃圾邮件)。


I am currently writing a music blog. The administrator posts a new article every 2-3 days. Once the administrator posts an article, a mass email will be sent to around 5000 subscribers immediately.

What is the best way to implement the mass mail feature?

Does the following function work?

function massmail() 
{
  $content = '...';
  foreach ($recipients as $r) {
    $_content = $content . '<img src="http://xxx/trackOpenRate.php?id='.$r.'">';
    mail($r, 'subject', $_content);
  }
}

Another question: If all 5000 subscribers are using Yahoo Mail, will Yahoo treat it as a DDOS attack and block the IP address of my SMTP server?

解决方案

First off, using the mail() function that comes with PHP is not an optimal solution. It is easily marked as spammed, and you need to set up header to ensure that you are sending HTML emails correctly. As for whether the code snippet will work, it would, but I doubt you will get HTML code inside it correctly without specifying extra headers

I'll suggest you take a look at SwiftMailer, which has HTML support, support for different mime types and SMTP authentication (which is less likely to mark your mail as spam).

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

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