Advertisement
Guest User

Untitled

a guest
Apr 3rd, 2018
673
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.63 KB | None | 0 0
  1. <?php
  2. use PHPMailer\PHPMailer\PHPMailer;
  3. use PHPMailer\PHPMailer\Exception;
  4.  
  5. require 'phpmailer/src/Exception.php';
  6. require 'phpmailer/src/PHPMailer.php';
  7. require 'phpmailer/src/SMTP.php';
  8. date_default_timezone_set('Etc/UTC');
  9. $mail = new PHPMailer;
  10. //Tell PHPMailer to use SMTP
  11. $mail->isSMTP();
  12. //Enable SMTP debugging
  13. // 0 = off (for production use)
  14. // 1 = client messages
  15. // 2 = client and server messages
  16. //Set the hostname of the mail server
  17. $mail->Host = 'smtp.gmail.com';
  18. // use
  19. // $mail->Host = gethostbyname('smtp.gmail.com');
  20. // if your network does not support SMTP over IPv6
  21. //Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
  22. $mail->Port = 587;
  23. //Set the encryption system to use - ssl (deprecated) or tls
  24. $mail->SMTPSecure = 'tls';
  25. //Whether to use SMTP authentication
  26. $mail->SMTPAuth = true;
  27. //Username to use for SMTP authentication - use full email address for gmail
  28. $mail->Username = "w.r.hasyim@gmail.com";
  29. //Password to use for SMTP authentication
  30. $mail->Password = "M1ftahulhuda";
  31. //Set who the message is to be sent from
  32. $mail->setFrom('w.r.hasyim@gmail.com', 'Wahyu Rusdiansyah');
  33. //Set an alternative reply-to address
  34. $mail->addReplyTo('w.r.hasyim@gmail.com', 'Wahyu Rusdiansyah');
  35. //Set who the message is to be sent to
  36. $mail->addAddress('intandesti25@gmail.com', 'intan destiyanti');
  37. //Set the subject line
  38. $mail->Subject = 'PHPMailer GMail SMTP test';
  39. //Replace the plain text body with one created manually
  40. $mail->Body = 'konek kan akhirnya aseek :v';
  41. $mail->AltBody = 'This is a plain-text message body';
  42. //send the message, check for errors
  43. $mail->send();
  44. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement