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. public $Host;
  19. public $Port;
  20. public $SMTPAuth=False;
  21. public $Username;
  22. public $Password;
  23. function __construct() {
  24. $this->SetLanguage("en", "lib/phpmailer/language/");
  25. //if SMTP_HOST is specified, use SMTP to send mail directly
  26. if (SMTP_HOST) {
  27. $Host = SMTP_HOST;
  28. $Mailer = "smtp";
  29. }
  30. //if SMTP_PORT is specified, assign it. Otherwise default to port 25
  31. if(SMTP_PORT){
  32. $Port = SMTP_PORT;
  33. }else{
  34. $Port = "25";
  35. }
  36. //if SMTP_LOGIN is specified, set credentials and enable auth
  37. if(SMTP_LOGIN){
  38. $SMTPAuth = true;
  39. $Username = SMTP_LOGIN;
  40. $Password = SMTP_PASSWORD;
  41. }
  42. }
  43. /* @brief a simple mail function to send email using the defaults
  44. * This will send an HTML email using the configured defaults
  45. * @param $toAddress A string with the recipients email address
  46. * @param $toName A string with the recipients name
  47. * @param $subject A string with the emails subject
  48. * @param $body A string containing the body of the email
  49. */
  50. public function quickMail ($toAddress, $toName, $subject, $body, $altbody=""){
  51. $this->addAddress($toAddress, $toName);
  52. $this->Subject = $subject;
  53. $this->Body = $body;
  54. $this->IsHTML($altbody != '');
  55. $rc=$this->send();
  56. return $rc;
  57. }
  58. }
  59. ?>