如何在不被任何垃圾邮件过滤器标记的情况下向数据库中的每个用户发送电子邮件?我假设您必须在一个月或更短的时间内全天发送电子邮件.当然,马上,我可以通过一个简单的查询获得所有用户的电子邮件地址,
select 'email' from 'users'但是实现这样一个任务的正确方法是我似乎迷失了...过去我使用过sendgrid等服务,但是为了避开所有垃圾邮件过滤器,这些公司遵循了哪些指导原则?
是的,你可以做到.按照给定的代码.
while($row = mysql_fetch_array($result))
{
$addresses[] = $row['email'];
}
$to = implode(", ", $addresses);
$subject = 'the subject';
$message = 'hello';
mail($to, "Your Subject", "A message set by you.", "If header information.");
Run Code Online (Sandbox Code Playgroud)
首先,您必须以逗号分隔的方式收集所有电子邮件地址.之后只需使用邮件功能同时向所有用户发送邮件.
如果您想单独发送邮件,请使用:
while($row = mysql_fetch_array($result))
{
$to = $row['email'];
$subject = 'the subject';
$message = 'hello';
mail($to, "Your Subject", "A message set by you.", "If header information.");
}
Run Code Online (Sandbox Code Playgroud)
更新: 由于mysql_*已弃用,请使用mysqli_*代替所有函数.
while($row = mysqli_fetch_array($result))
{
$addresses[] = $row['email'];
}
$to = implode(", ", $addresses);
$subject = 'the subject';
$message = 'hello';
mail($to, "Your Subject", "A message set by you.", "If header information.");
Run Code Online (Sandbox Code Playgroud)
和
while($row = mysqli_fetch_array($result))
{
$to = $row['email'];
$subject = 'the subject';
$message = 'hello';
mail($to, "Your Subject", "A message set by you.", "If header information.");
}
Run Code Online (Sandbox Code Playgroud)
请阅读mysqli_*的手册.
| 归档时间: |
|
| 查看次数: |
5151 次 |
| 最近记录: |