Advertisement
Guest User

Untitled

a guest
Jan 5th, 2019
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.58 KB | None | 0 0
  1. <?php
  2. // Import PHPMailer classes into the global namespace
  3. // These must be at the top of your script, not inside a function
  4. use PHPMailer\PHPMailer\PHPMailer;
  5. use PHPMailer\PHPMailer\Exception;
  6.  
  7. //Load Composer's autoloader
  8. require 'vendor/autoload.php';
  9.  
  10. $mail = new PHPMailer(true);                              // Passing `true` enables exceptions
  11. try {
  12.     //Server settings
  13.     $mail->SMTPDebug = 2;                                 // Enable verbose debug output
  14.     $mail->isSMTP();                                      // Set mailer to use SMTP
  15.     $mail->Host = 'smtp.yandex.ru';  // Specify main and backup SMTP servers
  16.     $mail->SMTPAuth = true;                               // Enable SMTP authentication
  17.     $mail->Username = 'adam.kasa@e-teambuilder.com';                 // SMTP username
  18.     $mail->Password = 'Adamkasa1379';                           // SMTP password
  19.     $mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
  20.     $mail->Port = 587;                                    // TCP port to connect to
  21.  
  22.     //Recipients
  23.     $mail->setFrom('adam.kasa@e-teambuilder.com');
  24.  
  25.     $mail->addAddress('samuel.schnelly@e-teambuilder.com');     // Add a recipient           // Name is optional
  26.    
  27.     //Content
  28.     $mail->isHTML(flase);                                  // Set email format to HTML
  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