Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
451
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 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();
  25. $mail->Host = "smtp.gmail.com";
  26. $mail->Port = 587;
  27. $mail->SMTPAuth = true;
  28. $mail->Username = "username@gmail.com";
  29. $mail->Password = "mygmailpass";
  30.  
  31. // Could assign strings directly to these, I only used the
  32. // former variables to illustrate how similar the two approaches are.
  33. $mail->FromName = $from_name;
  34. $mail->From = $from;
  35. $mail->AddAddress($to, $to_name);
  36. $mail->Subject = $subject;
  37. $mail->Body = $message;
  38.  
  39. $result = $mail->Send();
  40. echo $result ? 'Sent' : 'Error';
  41.  
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement