summaryrefslogtreecommitdiff
path: root/classes/ttrssmailer.php
diff options
context:
space:
mode:
authorderekmurawsky <[email protected]>2013-03-22 16:25:12 -0400
committerderekmurawsky <[email protected]>2013-03-22 16:25:12 -0400
commit1b2afd2bd3dc19cdd36da47cc52040a83cdb3b68 (patch)
tree286d5b99c3a895d2f756fae5c17a55122ee7a7f0 /classes/ttrssmailer.php
parent9d9432dab87e3887e4f482ac5afff1586530c692 (diff)
Additions:
classes/trssmailer.php - Created class TTRSS mailer which extends phpmailer and sets the default mail settings upon instantiation. Class includes quickmail function that allows for a quick email send with no extra configurion necessary. Changes: config.php-dist - Added the smtp port option include/digest.php - Converted it to use the new ttrrssmailer class include/sanity_config.php - Added the smtp port option to the sanity check plugins/mail/init.php - Modified to use ttrssmailer class. This particular configuration shows a hybrid use case. register.php = Modified to use ttrssmailer class. All code was tested and functioned on my local machine.
Diffstat (limited to 'classes/ttrssmailer.php')
-rw-r--r--classes/ttrssmailer.php63
1 files changed, 63 insertions, 0 deletions
diff --git a/classes/ttrssmailer.php b/classes/ttrssmailer.php
new file mode 100644
index 000000000..1b450c50c
--- /dev/null
+++ b/classes/ttrssmailer.php
@@ -0,0 +1,63 @@
+<?php
+/* @class ttrssMailer
+* @brief A TTRSS extension to the PHPMailer class
+* Configures default values through the __construct() function
+* @author Derek Murawsky
+* @version .1 (alpha)
+*
+*/
+require_once 'lib/phpmailer/class.phpmailer.php';
+require_once "config.php";
+
+class ttrssMailer extends PHPMailer {
+
+ //define all items that we want to override with defaults in PHPMailer
+ public $From = SMTP_FROM_ADDRESS;
+ public $FromName = SMTP_FROM_NAME;
+ public $CharSet = "UTF-8";
+ public $PluginDir = "lib/phpmailer/";
+ public $ContentType = "text/html"; //default email type is HTML
+ public $Host;
+ public $Port;
+ public $SMTPAuth=False;
+ public $Username;
+ public $Password;
+
+ function __construct() {
+ $this->SetLanguage("en", "lib/phpmailer/language/");
+ //if SMTP_HOST is specified, use SMTP to send mail directly
+ if (SMTP_HOST) {
+ $Host = SMTP_HOST;
+ $Mailer = "smtp";
+ }
+ //if SMTP_PORT is specified, assign it. Otherwise default to port 25
+ if(SMTP_PORT){
+ $Port = SMTP_PORT;
+ }else{
+ $Port = "25";
+ }
+
+ //if SMTP_LOGIN is specified, set credentials and enable auth
+ if(SMTP_LOGIN){
+ $SMTPAuth = true;
+ $Username = SMTP_LOGIN;
+ $Password = SMTP_PASSWORD;
+ }
+ }
+ /* @brief a simple mail function to send email using the defaults
+ * This will send an HTML email using the configured defaults
+ * @param $toAddress A string with the recipients email address
+ * @param $toName A string with the recipients name
+ * @param $subject A string with the emails subject
+ * @param $body A string containing the body of the email
+ */
+ public function quickMail ($toAddress, $toName, $subject, $body, $altbody=""){
+ $this->addAddress($toAddress, $toName);
+ $this->Subject = $subject;
+ $this->Body = $body;
+ $rc=$this->send();
+ return $rc;
+ }
+}
+
+?> \ No newline at end of file