Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
1,491
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.88 KB | None | 0 0
  1. use PHPMailer\PHPMailer\PHPMailer;
  2. use PHPMailer\PHPMailer\Exception;
  3.  
  4. require 'phpmailer/src/Exception.php';
  5. require 'phpmailer/src/PHPMailer.php';
  6. require 'phpmailer/src/SMTP.php';
  7.  
  8.  
  9. $mail = new PHPMailer(true);  
  10. try {
  11.  
  12.     $mail->SMTPDebug = 1;
  13.     $mail->isSMTP();
  14.     $mail->Host = 'smtp.gmail.com';
  15.     $mail->Port = 587;
  16.     $mail->SMTPAuth = true;
  17.     $mail->Username = 'email@email.com';
  18.     $mail->Password = 'password';
  19.     $mail->SMTPSecure = 'tsl';
  20.  
  21.     //Recipients
  22.     $mail->setFrom('email@email.com', 'email');
  23.     $mail->addAddress('email@email.com');
  24.     $mail->addAddress('email@email.com');
  25.  
  26.  
  27.     //Content
  28.     $mail->isHTML(true);
  29.     $mail->Subject = 'test';
  30.     $mail->Body = 'test';
  31.  
  32.  
  33.     $mail->send();
  34.     echo 'Message has been sent';
  35. } catch (Exception $e) {
  36.     echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement