Advertisement
Guest User

Untitled

a guest
Mar 25th, 2021
116
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /*
  3. //Import PHPMailer classes into the global namespace
  4. //These must be at the top of your script, not inside a function*/
  5.  
  6. use PHPMailer\PHPMailer\PHPMailer;
  7. use PHPMailer\PHPMailer\SMTP;
  8. use PHPMailer\PHPMailer\Exception;
  9.  
  10. require 'vendor/phpmailer/phpmailer/src/PHPMailer.php';
  11. require 'vendor/phpmailer/phpmailer/src/SMTP.php';
  12. require 'vendor/phpmailer/phpmailer/src/Exception.php';
  13.  
  14.  
  15. //Load Composer's autoloader
  16. require 'vendor/autoload.php';
  17.  
  18. try {
  19.     //Server settings
  20.     $mail->SMTPDebug = SMTP::DEBUG_SERVER;                      //Enable verbose debug output
  21.     $mail->isSMTP();                                            //Send using SMTP
  22.     $mail->Host       = 'smtp.example.com';                     //Set the SMTP server to send through
  23.     $mail->SMTPAuth   = true;                                   //Enable SMTP authentication
  24.     $mail->Username   = 'user@example.com';                     //SMTP username
  25.     $mail->Password   = 'secret';                               //SMTP password
  26.     $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;         //Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
  27.     $mail->Port       = 587;                                    //TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above
  28.  
  29.     //Recipients
  30.     $mail->setFrom('from@example.com', 'Mailer');
  31.     $mail->addAddress('joe@example.net', 'Joe User');     //Add a recipient
  32.     $mail->addAddress('ellen@example.com');               //Name is optional
  33.     $mail->addReplyTo('info@example.com', 'Information');
  34.     $mail->addCC('cc@example.com');
  35.     $mail->addBCC('bcc@example.com');
  36.  
  37.     //Content
  38.     $mail->isHTML(true);                                  //Set email format to HTML
  39.     $mail->Subject = 'Here is the subject';
  40.     $mail->Body    = 'This is the HTML message body <b>in bold!</b>';
  41.     $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
  42.  
  43.     $mail->send();
  44.     echo 'Message has been sent';
  45. } catch (Exception $e) {
  46.     echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
  47. }
  48.  
  49. ?>
  50.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement