通过PHP的SMTP电子邮件 - 通过发送网格


SMTP email via PHP - through Send Grid

我正在使用SendGrid SMTP邮件服务从我的PHP网站发送SMTP电子邮件。一切正常,但是当我发送大量(5,000(时,加载/发送需要很长时间,然后尝试一遍又一遍地重新启动,然后翻倍,三倍,....我只是错误地发送了 30,000 封电子邮件!我需要一种方法来查看邮件 que 并删除它们或在执行此操作时停止进程。

  • 如何查看要发送的电子邮件的查询?还是取消他们被发送出去?
  • 也许通过珍珠邮件?

这是我的代码

 require_once "Mail.php";

 $from = $thom5;
 $to = $allemailsever1.','.$thom5;
  $subject = $_POST['subject1'];
 $html   = "
<html><body>
<p></p>
$thom
</body></html>
"; 
$host = "smtp.sendgrid.net";
$port = "587";
$username5 = "";
$password5 = "";
$mime = '1.0';
$content = 'text/html'; 
$charset="ISO-8859-1";
$three = 'Receipients <'.$thom5.'>';

$headers = array ('From' => $from,
  'To' => $three,
'Subject' => $subject,
'Mime-version' => $mime,
'Content-Type' => $content,
'charset' => $charset);

$smtp = Mail::factory('smtp',
 array ('host' => $host,
 'port' => $port,
 'auth' => true,
 'username' => $username5,
 'password' => $password5));
// Send notification //

$mail = $smtp->send($to, $headers, $html);

听起来您的本地脚本在管理您尝试发送的邮件数量时遇到问题。您应该实现本地队列,并且由于您使用的是PHP,因此一个简单的选项是Mail_Queue PEAR包

使用事件 API 并检查是否处理了每条消息。 http://docs.sendgrid.com/documentation/api/event-api/