2
votes

I am sending SMTP email from my PHP website, using SendGrid SMTP mail service. Everything works fine, but when I send large amounts (5,000), it takes a long time to load/send, then tries to restart over and over again, and doubles, triples,.... I just sent 30,000 emails by mistake! I need a way to see the mail que and delete them or stop the process when it does this.

  • How can I see the que of emails to be sent out? Or cancel them from being sent out?
  • Maybe through Pearl Mail?

Here is my code

 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);
2

2 Answers

2
votes

Sounds like your local script is having trouble managing the number of mails you are trying to send. You should implement a local queue, and since you are using PHP, a simple option is the Mail_Queue PEAR package

1
votes

Use the Events API and check to see that each message is processed. http://docs.sendgrid.com/documentation/api/event-api/