phpmailer.php 781 B

12345678910111213141516171819202122
  1. <?php
  2. use PHPMailer\PHPMailer\PHPMailer;
  3. require 'vendor/autoload.php';
  4. $mail = new PHPMailer;
  5. $mail->isSMTP();
  6. $mail->SMTPDebug = 2;
  7. $mail->Host = getenv('MAIL_SMTP_SERVER');
  8. $mail->Port = getenv('MAIL_SMTP_PORT');
  9. $mail->SMTPAuth = true;
  10. $mail->Username = getenv('MAIL_SMTP_USERNAME');
  11. $mail->Password = getenv('MAIL_SMTP_PASSWORD');
  12. $mail->setFrom(getenv('MAIL_FROM'), 'Cloudron LAMP App');
  13. $mail->addAddress('mail@girish.in', 'Girish Ramakrishnan');
  14. $mail->Subject = 'PHPMailer SMTP message (via Cloudron)';
  15. $mail->isHTML(true);
  16. $mail->Body = '<h2>Send HTML Email using SMTP in PHP</h2>';
  17. if (!$mail->send()) {
  18. echo 'Mailer Error: ' . $mail->ErrorInfo;
  19. } else {
  20. echo 'Message sent!';
  21. }
  22. ?>