Advertisement
sir_dutton

Untitled

Nov 1st, 2018
581
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.53 KB | None | 0 0
  1. <?php
  2.  
  3. use PHPMailer\PHPMailer\PHPMailer;
  4. use PHPMailer\PHPMailer\Exception;
  5.  
  6.  
  7. /* Exception class */
  8.  
  9. require '\PHPMailer\src\Exception.php';
  10.  
  11. /* The Main PHPMailer class */
  12.  
  13. require '\PHPMailer\src\PHPMailer.php';
  14.  
  15. /* SMTP class */
  16.  
  17. require '\PHPMailer\src\SMTP.php';
  18.  
  19. $mail = new PHPMailer(TRUE);
  20.  
  21. try {
  22.     /* Set the mail sender. */
  23.     $mail->setFrom('sender email', 'person');
  24.      
  25.     /* Add a recipient. */
  26.     $mail->addAddress('add recipient', 'person');
  27.      
  28.     /* Set the subject. */
  29.     $mail->Subject = 'Test';
  30.      
  31.     /* Set the mail message body. */
  32.     $mail->Body = '<html>I am testing PHPMailer and <strong>HTML</strong>.</html>';
  33.  
  34.        /* SMTP parameters. */
  35.    
  36.    /* Tells PHPMailer to use SMTP. */
  37.    $mail->isSMTP();
  38.    $mail->SMTPDebug=4;
  39.    
  40.    /* SMTP server address. */
  41.    $mail->Host = 'smtp.gmail.com';
  42.  
  43.    /* Use SMTP authentication. */
  44.    $mail->SMTPAuth = TRUE;
  45.    
  46.    /* Set the encryption system. */
  47.    $mail->SMTPSecure = 'tls';
  48.    
  49.    /* SMTP authentication username. */
  50.    $mail->Username = 'something@here.com';
  51.    
  52.    /* SMTP authentication password. */
  53.    $mail->Password = 'something here';
  54.    
  55.    /* Set the SMTP port. */
  56.    $mail->Port = 587;
  57.      
  58.     /* Finally send the mail. */
  59.     $mail->send();
  60. }
  61. catch (Exception $e)
  62. {
  63.        /* PHPMailer exception. */
  64.    echo $e->errorMessage();
  65. }
  66. catch (\Exception $e)
  67. {
  68.    /* PHP exception (note the backslash to select the global namespace Exception class). */
  69.    echo $e->getMessage();
  70. }
  71.  
  72.  
  73.  
  74. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement