MJScharen

phpmailerTest.php

Jan 21st, 2022 (edited)
104
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. use PHPMailer\PHPMailer\PHPMailer;
  4. use PHPMailer\PHPMailer\Exception;
  5. require 'vendor\autoload.php';
  6.  
  7. $mail = new PHPMailer(TRUE);
  8. echo "Running PHPMailer Test Message";
  9. try {
  10.    
  11.    $mail->setFrom('MJSBookORders@post.com', 'Michael\'s Book Corner');
  12.    $mail->addAddress('mscharene@mail.com', 'Customer');
  13.    $mail->Subject = 'Recent Order';
  14.    $mail->isHTML(TRUE);
  15.    $mail->Body = '<html><img src="I-Images/VallisMarineris.jpg">Thank you for your order! This is your order confirmation.</html>';
  16.    $mail->AltBody = 'Thank you for your order! This is your order confirmation.';
  17.    
  18.    /* SMTP parameters. */
  19.    
  20.    /* Tells PHPMailer to use SMTP. */
  21.    $mail->isSMTP();
  22.    
  23.    /* SMTP server address. */
  24.    $mail->Host = 'smtp.mail.com';
  25.    $mail->SMTPDebug  = 2;
  26.    /* Use SMTP authentication. */
  27.    $mail->SMTPAuth = TRUE;
  28.    
  29.    /* Set the encryption system. */
  30.    $mail->SMTPSecure = 'tls';
  31.    
  32.    /* SMTP authentication username. */
  33.    $mail->Username = 'MJSBookOrders@post.com';
  34.    
  35.    /* SMTP authentication password. */
  36.    $mail->Password = 'WeSendYouTheBookXX1';
  37.    
  38.    /* Set the SMTP port. */
  39.    $mail->Port = 465;
  40.    
  41.    /* Finally send the mail. */
  42.    $mail->send();
  43. }
  44. catch (Exception $e)
  45. {
  46.    echo $e->errorMessage();
  47. }
  48. catch (\Exception $e)
  49. {
  50.    echo $e->getMessage();
  51. }
RAW Paste Data Copied