Guest User

Untitled

a guest
Dec 13th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. <?php
  2.  
  3. use PHPMailer\PHPMailer\PHPMailer;
  4. use PHPMailer\PHPMailer\Exception;
  5.  
  6. include_once "PHPMailer/PHPMailer.php";
  7. include_once "PHPMailer/Exception.php";
  8. include_once "PHPMailer/SMTP.php";
  9.  
  10. function send_mail($to,$subject,$body){
  11. // Import PHPMailer classes into the global namespace
  12. // These must be at the top of your script, not inside a function
  13.  
  14.  
  15. $mail = new PHPMailer(true); // Passing `true` enables exceptions
  16.  
  17. //Server settings
  18. $mail->SMTPDebug = 0; // Enable verbose debug output
  19. $mail->isSMTP(); // Set mailer to use SMTP
  20. $mail->Host = 'YOUR_HOST_HERE'; // Specify main and backup SMTP servers
  21. $mail->SMTPAuth = true; // Enable SMTP authentication
  22. $mail->Username = 'YOUR_SMTP_USERNAME'; // SMTP username
  23. $mail->Password = 'YOUR_SMTP_PASSWORD'; // SMTP password
  24. $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
  25. $mail->Port = 587; // TCP port to connect to
  26.  
  27. //Recipients
  28. $mail->setFrom('YOUR_EMAIL_ADDRESS', 'YOURNAME'); //SET "FROM" EMAIL AND NAME.
  29. // IT SHOULD BE LIKE THIS, $mail->setFrom('info@hackerrahul.com', 'HackerRahul');
  30.  
  31.  
  32. $mail->addAddress($to); // Add a recipient
  33.  
  34. //Content
  35. $mail->isHTML(true); // Set email format to HTML
  36. $mail->Subject = $subject; // Subject of the Email
  37. $mail->Body = $body; // Body of the Email
  38.  
  39. if($mail->send()){
  40. $response = '1';
  41. }else{
  42. $response = '0';
  43. }
  44. return $response;
  45. }
  46.  
  47.  
  48. ?>
Add Comment
Please, Sign In to add comment