title: SMTP email via PHP - through Send Grid
body: <p>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.</p>
  
  <ul>
  <li>How can I see the que of emails to be sent out? Or cancel them from being sent out?</li>
  <li>Maybe through Pearl Mail?</li>
  </ul>
  
  <p>Here is my code </p>
  
  <pre><code> require_once "Mail.php";
  
  
  
   $from = $thom5;
   $to = $allemailsever1.','.$thom5;
    $subject = $_POST['subject1'];
   $html   = "
  &lt;html&gt;&lt;body&gt;
  &lt;p&gt;&lt;/p&gt;
  $thom
  &lt;/body&gt;&lt;/html&gt;
  "; 
  
  $host = "smtp.sendgrid.net";
  $port = "587";
  $username5 = "";
  $password5 = "";
  
  $mime = '1.0';
  $content = 'text/html'; 
  $charset="ISO-8859-1";
  
  $three = 'Receipients &lt;'.$thom5.'&gt;';
  
  
  $headers = array ('From' =&gt; $from,
    'To' =&gt; $three,
  'Subject' =&gt; $subject,
  'Mime-version' =&gt; $mime,
  'Content-Type' =&gt; $content,
  'charset' =&gt; $charset);
  
  
  
  $smtp = Mail::factory('smtp',
   array ('host' =&gt; $host,
   'port' =&gt; $port,
   'auth' =&gt; true,
   'username' =&gt; $username5,
   'password' =&gt; $password5));
  
  // Send notification //
  
  
  $mail = $smtp-&gt;send($to, $headers, $html);
  </code></pre>