ttrssmailer.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 (!$Port) $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. }
  37. /* @brief a simple mail function to send email using the defaults
  38. * This will send an HTML email using the configured defaults
  39. * @param $toAddress A string with the recipients email address
  40. * @param $toName A string with the recipients name
  41. * @param $subject A string with the emails subject
  42. * @param $body A string containing the body of the email
  43. */
  44. public function quickMail ($toAddress, $toName, $subject, $body, $altbody=""){
  45. $this->addAddress($toAddress, $toName);
  46. $this->Subject = $subject;
  47. $this->Body = $body;
  48. $this->IsHTML($altbody != '');
  49. $rc=$this->send();
  50. return $rc;
  51. }
  52. }
  53. ?>