Advertisement
Guest User

Untitled

a guest
Aug 13th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 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 = 3; // Enable verbose debug output
  14. $mail->isSMTP(); // Set mailer to use SMTP
  15. $mail->Host = 'mail.donaluajoias.com.br'; // Specify main and backup SMTP servers
  16. $mail->SMTPAuth = true; // Enable SMTP authentication
  17. $mail->Username = 'admin@donaluajoias.com.br'; // SMTP username
  18. $mail->Password = 'd2030187'; // SMTP password
  19. $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
  20. $mail->Port = 587; // TCP port to connect to
  21. $mail->SMTPAutoTLS = true;
  22.  
  23. //Recipients
  24. $mail->setFrom('admin@donaluajoias.com.br', 'Dona Lua Joias');
  25. $mail->addAddress('mateus@studiogt.com.br', 'Mateus'); // Add a recipient
  26. $mail->addAddress('sergio@studiogt.com.br', 'Sergio'); // Name is optional
  27.  
  28. //Content
  29. $mail->isHTML(true); // Set email format to HTML
  30. $mail->Subject = 'Teste PHPMailer';
  31. $mail->Body = 'This is the HTML message body <b>in bold!</b>';
  32. $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
  33.  
  34. $mail->send();
  35. echo 'Message has been sent';
  36. } catch (Exception $e) {
  37. echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement