Advertisement
Guest User

Untitled

a guest
Nov 21st, 2016
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. <?php
  2.  
  3. date_default_timezone_set('Etc/UTC');
  4.  
  5. require 'phpmailer/PHPMailerAutoload.php';
  6.  
  7. //Create a new PHPMailer instance
  8. $mail = new PHPMailer;
  9.  
  10. //Tell PHPMailer to use SMTP
  11. $mail->isSMTP();
  12.  
  13. //Enable SMTP debugging
  14. // 0 = off (for production use)
  15. // 1 = client messages
  16. // 2 = client and server messages
  17. $mail->SMTPDebug = 2;
  18.  
  19. //Ask for HTML-friendly debug output
  20. $mail->Debugoutput = 'html';
  21.  
  22. //Set the hostname of the mail server
  23. $mail->Host = 'smtp.gmail.com';
  24. // use
  25. // $mail->Host = gethostbyname('smtp.gmail.com');
  26. // if your network does not support SMTP over IPv6
  27.  
  28. //Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
  29. $mail->Port = 587;
  30.  
  31. //Set the encryption system to use - ssl (deprecated) or tls
  32. $mail->SMTPSecure = 'tls';
  33.  
  34. //Whether to use SMTP authentication
  35. $mail->SMTPAuth = true;
  36.  
  37. //Username to use for SMTP authentication - use full email address for gmail
  38. $mail->Username = "cs.imaskot@gmail.com";
  39.  
  40. //Password to use for SMTP authentication
  41. $mail->Password = "pass";
  42.  
  43. //Set who the message is to be sent from
  44. $mail->setFrom('cs.imaskot@gmail.com', 'APLIKASI IMASKOT');
  45.  
  46. //Set an alternative reply-to address
  47. $mail->addReplyTo('cs.imaskot@gmail.com', 'APLIKASI IMASKOT');
  48.  
  49. //Set who the message is to be sent to
  50. $mail->addAddress('cs.imaskot@gmail.com', 'John Doe');
  51.  
  52. //Set the subject line
  53. $mail->Subject = 'PHPMailer GMail SMTP test';
  54.  
  55. //Read an HTML message body from an external file, convert referenced images to embedded,
  56. //convert HTML into a basic plain-text alternative body
  57. $mail->msgHTML(file_get_contents('phpmailer/examples/contents.html'), dirname(__FILE__));
  58.  
  59. //Replace the plain text body with one created manually
  60. $mail->AltBody = 'This is a plain-text message body';
  61.  
  62. //Attach an image file
  63. $mail->addAttachment('phpmailer/examples/images/phpmailer_mini.png');
  64.  
  65. //send the message, check for errors
  66. if (!$mail->send()) {
  67. echo "Mailer Error: " . $mail->ErrorInfo;
  68. } else {
  69. echo "Message sent!";
  70. }
  71.  
  72. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement