ttrssmailer.php 1.8 KB

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