Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
564
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. <?php
  2. //Import PHPMailer classes into the global namespace
  3. use PHPMailer\PHPMailer\PHPMailer;
  4. use PHPMailer\PHPMailer\Exception;
  5.  
  6. require_once 'vendor/autoload.php';
  7.  
  8. $mail = new PHPMailer(true);
  9.  
  10. try {
  11. //$mail->isSMTP();
  12. $mail->Host = 'smtp.googlemail.com'; //gmail SMTP server
  13. $mail->SMTPAuth = true;
  14. $mail->Username = ‘email@gmail.com'; //username
  15. $mail->Password = ‘password’; //password
  16. $mail->SMTPSecure = 'ssl';
  17. $mail->Port = 465; //smtp port
  18.  
  19. $mail->setFrom('noreply@artisansweb.net', 'Artisans Web');
  20. //Set who the message is to be sent to
  21. $mail->addAddress(‘user@gmail.com', 'User Name');
  22.  
  23.  
  24. $mail->isHTML(true);
  25.  
  26. $mail->Subject = 'Email Subject';
  27. $mail->Body = 'Email Body';
  28.  
  29. if (!$mail->send()) {
  30. echo 'Message could not be sent.';
  31. echo 'Mailer Error: ' . $mail->ErrorInfo;
  32. } else {
  33. echo 'Message has been sent';
  34. }
  35. } catch (Exception $e) {
  36. echo 'Message could not be sent.';
  37. echo 'Mailer Error: ' . $mail->ErrorInfo;
  38. }
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement