TD_27

Mass Mailer using Gmail SMTP

May 16th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.77 KB | None | 0 0
  1. <?php
  2. include 'maillist-mentah.php';
  3.   $res = preg_match_all(
  4.     "/([a-z0-9]+([_\\.-][a-z0-9]+)*)@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}/i",
  5.     $emaillist_mentah,
  6.     $emaillist_data
  7.   );
  8.  
  9. /**
  10.  * This example shows settings to use when sending via Google's Gmail servers.
  11.  */
  12.  $berak= "normal <b>bold";
  13.  
  14. //SMTP needs accurate times, and the PHP time zone MUST be set
  15. //This should be done in your php.ini, but this is how to do it if you don't have access to that
  16. date_default_timezone_set('Etc/UTC');
  17.  
  18. require 'PHPMailerAutoload.php';
  19.  
  20. //Create a new PHPMailer instance
  21.  
  22. $mail = new PHPMailer;
  23.  
  24. //Tell PHPMailer to use SMTP
  25. $mail->isSMTP();
  26.  
  27. //Enable SMTP debugging
  28. // 0 = off (for production use)
  29. // 1 = client messages
  30. // 2 = client and server messages
  31. $mail->SMTPDebug = 0;
  32.  
  33. //Ask for HTML-friendly debug output
  34. $mail->Debugoutput = 'html';
  35.  
  36. //Set the hostname of the mail server
  37. $mail->Host = 'smtp.gmail.com';
  38. // use
  39. // $mail->Host = gethostbyname('smtp.gmail.com');
  40. // if your network does not support SMTP over IPv6
  41.  
  42. //Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
  43. $mail->Port = 587;
  44.  
  45. //Set the encryption system to use - ssl (deprecated) or tls
  46. $mail->SMTPSecure = 'tls';
  47.  
  48. //Whether to use SMTP authentication
  49. $mail->SMTPAuth = true;
  50. $mail->SMTPKeepAlive = true;
  51. //Username to use for SMTP authentication - use full email address for gmail
  52. $mail->Username = "nitaayuriski@gmail.com";
  53.  
  54. //Password to use for SMTP authentication
  55. $mail->Password = "memek56t";
  56. $mail->FromName = 'Root User';
  57. //Set who the message is to be sent from
  58. $mail->From = 'tdazzly27@gmail.com';
  59. //Set an alternative reply-to address
  60. //$mail->addReplyTo('replyto@example.com', 'First Last');
  61.  
  62. //Set who the message is to be sent to
  63. //Set the subject line
  64. $mail->Subject = 'PHPMailer GMail SMTP test';
  65.  
  66. //Read an HTML message body from an external file, convert referenced images to embedded,
  67. //convert HTML into a basic plain-text alternative body
  68. //$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
  69.  
  70. //Replace the plain text body with one created manually
  71.         $mail->Body = <<<EOT
  72.         $berak
  73. EOT;
  74. $mail->IsHTML(true);  
  75. //Attach an image file
  76. //$mail->addAttachment('images/phpmailer_mini.png');
  77.  
  78. //$mail->addAddress('tdazzly27@gmail.com');
  79. for($x=0;$x<count($emaillist_data[0]);$x++){
  80.      foreach($emaillist_data as $emailkey) {
  81.     $mail->addAddress($emailkey[$x]);     // Add a recipient
  82.    
  83.  
  84.  
  85. //send the message, check for errors
  86.  
  87.     if(!$mail->send()[$x]) {
  88.        echo "<title>Success</title><br><br>shshzh";
  89.     } {
  90.         echo "<title>Success</title><font color='green'>Message has been sent From " .$mail->From. " to ".$."<br><br>";
  91.     }
  92.  
  93.     $mail->ClearAllRecipients();
  94.  
  95.   }
  96. }
Add Comment
Please, Sign In to add comment