ttrssmailer.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /* @class ttrssMailer
  3. * @brief A TTRSS extension to the PHPMailer class
  4. * Configures default values through the __construct() function
  5. * @author Derek Murawsky
  6. * @version .1 (alpha)
  7. *
  8. */
  9. require_once 'lib/phpmailer/class.phpmailer.php';
  10. require_once 'lib/phpmailer/class.smtp.php';
  11. require_once "config.php";
  12. class ttrssMailer extends PHPMailer {
  13. //define all items that we want to override with defaults in PHPMailer
  14. public $From = SMTP_FROM_ADDRESS;
  15. public $FromName = SMTP_FROM_NAME;
  16. public $CharSet = "UTF-8";
  17. public $PluginDir = "lib/phpmailer/";
  18. public $ContentType = "text/html"; //default email type is HTML
  19. function __construct() {
  20. $this->SetLanguage("en", "lib/phpmailer/language/");
  21. if (SMTP_SERVER) {
  22. $pair = explode(":", SMTP_SERVER, 2);
  23. $this->Mailer = "smtp";
  24. $this->Host = $pair[0];
  25. $this->Port = $pair[1];
  26. if (!$this->Port) $this->Port = 25;
  27. } else {
  28. $this->Host = '';
  29. $this->Port = '';
  30. }
  31. //if SMTP_LOGIN is specified, set credentials and enable auth
  32. if(SMTP_LOGIN){
  33. $this->SMTPAuth = true;
  34. $this->Username = SMTP_LOGIN;
  35. $this->Password = SMTP_PASSWORD;
  36. }
  37. if(SMTP_SECURE)
  38. $this->SMTPSecure = SMTP_SECURE;
  39. }
  40. /* @brief a simple mail function to send email using the defaults
  41. * This will send an HTML email using the configured defaults
  42. * @param $toAddress A string with the recipients email address
  43. * @param $toName A string with the recipients name
  44. * @param $subject A string with the emails subject
  45. * @param $body A string containing the body of the email
  46. */
  47. public function quickMail ($toAddress, $toName, $subject, $body, $altbody=""){
  48. $this->addAddress($toAddress, $toName);
  49. $this->Subject = $subject;
  50. $this->Body = $body;
  51. $this->IsHTML($altbody != '');
  52. $rc=$this->send();
  53. return $rc;
  54. }
  55. }