Advertisement
Guest User

gmail.php

a guest
Aug 1st, 2017
614
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. #!/usr/bin/php -q
  2. <?php
  3. /**
  4. * This example shows settings to use when sending via Google's Gmail servers.
  5. */
  6.  
  7. //SMTP needs accurate times, and the PHP time zone MUST be set
  8. //This should be done in your php.ini, but this is how to do it if you don't have access to that
  9. if ($argc < 3) {
  10. echo "Usage: gmail.php email message\n";
  11. exit;
  12. }
  13.  
  14. date_default_timezone_set('Etc/UTC');
  15.  
  16.  
  17. require '/etc/zabbix/alertscripts/PHPMailerAutoload.php';
  18.  
  19. //Create a new PHPMailer instance
  20. $mail = new PHPMailer;
  21.  
  22. //Tell PHPMailer to use SMTP
  23. $mail->isSMTP();
  24.  
  25. //Enable SMTP debugging
  26. // 0 = off (for production use)
  27. // 1 = client messages
  28. // 2 = client and server messages
  29. $mail->SMTPDebug = 0;
  30.  
  31. //Ask for HTML-friendly debug output
  32. $mail->Debugoutput = 'html';
  33.  
  34. //Set the hostname of the mail server
  35. $mail->Host = 'smtp.gmail.com';
  36.  
  37. //Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
  38. $mail->Port = 587;
  39.  
  40. //Set the encryption system to use - ssl (deprecated) or tls
  41. $mail->SMTPSecure = 'tls';
  42.  
  43. //Whether to use SMTP authentication
  44. $mail->SMTPAuth = true;
  45.  
  46. //Username to use for SMTP authentication - use full email address for gmail
  47. $mail->Username = "youremail-idc@gmail.com";
  48.  
  49. //Password to use for SMTP authentication
  50. //$mail->Password = "NmzfUCUH";
  51. //$mail->Password = "leqnllchiuddfucl";
  52. //$mail->Password = "vqbuhypbpyytvets";
  53. $mail->Password = "Adfnsd22323";
  54.  
  55. //Set who the message is to be sent from
  56. $mail->setFrom('youremail-idc@gmail.com', 'TTV Monitor');
  57.  
  58. //Set an alternative reply-to address
  59. //$mail->addReplyTo('replyto@example.com', 'First Last');
  60.  
  61. //Set who the message is to be sent to
  62. //$mail->addAddress('viet.bui@ttvonline.com.vn', 'Viet');
  63. $mail->addAddress($argv[1], 'TTV System');
  64.  
  65. //Set the subject line
  66. $mail->Subject = "$argv[2]";
  67.  
  68. //Read an HTML message body from an external file, convert referenced images to embedded,
  69. //convert HTML into a basic plain-text alternative body
  70. //$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
  71. $mail->msgHTML($argv[3]);
  72.  
  73. //Replace the plain text body with one created manually
  74. //$mail->AltBody = "$argv[2]";
  75.  
  76. //Attach an image file
  77. //$mail->addAttachment('images/phpmailer_mini.png');
  78.  
  79. //send the message, check for errors
  80. if (!$mail->send()) {
  81. echo "Mailer Error: " . $mail->ErrorInfo;
  82. } else {
  83. echo "Message sent!";
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement