Guest User

Untitled

a guest
Feb 15th, 2019
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. <?php
  2. // 1. include PHPMailerAutoload.php
  3. require 'phpmailer/PHPMailerAutoload.php';
  4.  
  5.  
  6. // 2. create an instance of PHPMailer
  7. $mail = new PHPMailer();
  8.  
  9. // 3. set a host
  10. $mail->Host = "smtp.gmail.com";
  11.  
  12. // 4. enable SMTP
  13. // $mail->isSMTP();
  14.  
  15. // 5. set authentication to true
  16. $mail->SMTPAuth = true;
  17.  
  18. // 6. set login details for gmail account
  19. $mail->Username = "md.mahbub7931@gmail.com";
  20. $mail->Password = "mahbub01814724579";
  21.  
  22. // 7. set type of protection
  23. $mail->SMTPSecure = "ssl"; // or we can use TLS
  24.  
  25. // 8. set a port
  26. $mail->Port = 465; // or 587 if TLS or 80 if TLS and SSL not have.
  27.  
  28. // 9. set subject
  29. $mail->Subject = "test email";
  30.  
  31. // set html to true
  32. $mail->isHTML(true);
  33.  
  34. // 10.set body
  35. $mail->Body = "this is our body..";
  36.  
  37.  
  38.  
  39. // 11.set who is sending an email
  40. $mail->setFrom('redhatmahbub@gmail.com','redhatmahbub');
  41.  
  42. // 12.set where we are sending email (recipients)
  43. $mail->addAddress('md.mahbub7931@gmail.com');
  44. // 13.send an email
  45. if($mail->send()){
  46. echo "mail is sent";
  47. }
  48. else
  49. {
  50. echo "something wrong happen";
  51. }
  52.  
  53. ?>
Add Comment
Please, Sign In to add comment