Advertisement
Guest User

Untitled

a guest
Jul 29th, 2017
460
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. <?php
  2.  
  3. // Include the PHPMailer classes
  4. // If these are located somewhere else, simply change the path.
  5. require_once("PHPMailer/class.phpmailer.php");
  6. require_once("PHPMailer/class.smtp.php");
  7. require_once("PHPMailer/language/phpmailer.lang-ar.php");
  8.  
  9. // mostly the same variables as before
  10. // ($to_name & $from_name are new, $headers was omitted)
  11. $to_name = "tp mail";
  12. $to = "sunil.gandhi007@gmail.com";
  13. $subject = "Mail Test at ".strftime("%T", time());
  14. $message = "This is a test.";
  15. $message = wordwrap($message,70);
  16. $from_name = "sunil";
  17. $from = "sunil.gandhi007@gmail.com";
  18.  
  19. // PHPMailer's Object-oriented approach
  20. $mail = new PHPMailer();
  21.  
  22. // Can use SMTP
  23. // comment out this section and it will use PHP mail() instead
  24. $mail->IsSMTP(); // telling the class to use SMTP
  25. $mail->Host = "smtp.gmail.com"; // SMTP server
  26. // enables SMTP debug information (for testing) // 1 = errors and messages // 2 = messages only
  27. $mail->SMTPDebug = 2;
  28. $mail->SMTPAuth = true; // enable SMTP authentication
  29. $mail->SMTPSecure = "tls"; // sets the prefix to the servier
  30. $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
  31. $mail->Port = 587; // set the SMTP port for the GMAIL server
  32. $mail->Username = "sunil.gandhi007@gmail.com"; // GMAIL username
  33. $mail->Password = "***************"; // GMAIL password
  34.  
  35. $mail->FromName = $from_name;
  36. $mail->From = $from;
  37. $mail->AddAddress($to, $to_name);
  38. $mail->Subject = $subject;
  39. $mail->Body = $message;
  40.  
  41. $result = $mail->Send();
  42. echo $result ? 'Sent' : 'Error';
  43.  
  44. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement