mailsender.php 914 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. require '../lib/phpmailer/Exception.php';
  3. require '../lib/phpmailer/PHPMailer.php';
  4. require '../lib/phpmailer/SMTP.php';
  5. require_once ('../config/linequest.php');
  6. use PHPMailer\PHPMailer\PHPMailer;
  7. use PHPMailer\PHPMailer\SMTP;
  8. use PHPMailer\PHPMailer\Exception;
  9. function send_mail($recipient, $subject, $message) {
  10. global $CFG;
  11. $mail = new PHPMailer(true);
  12. $mail->isSMTP();
  13. $mail->SMTPDebug = 2;
  14. $mail->Host = $CFG->smtp->host;
  15. $mail->Port = $CFG->smtp->port;
  16. $mail->SMTPAuth = true;
  17. $mail->Username = $CFG->smtp->username;
  18. $mail->Password = $CFG->smtp->password;
  19. $mail->CharSet = 'UTF-8';
  20. $mail->setFrom($CFG->smtp->from, $CFG->smtp->from);
  21. $mail->addReplyTo($CFG->smtp->from, 'no-reply');
  22. $mail->IsHTML(true);
  23. $mail->addAddress($recipient, $recipient);
  24. $mail->Subject = $subject;
  25. $mail->Body = $message;
  26. return $mail->send();
  27. }
  28. ?>