2013-03-22 20:25:12 +00:00
|
|
|
<?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;
|
2013-03-23 05:20:16 +00:00
|
|
|
|
2013-03-22 20:25:12 +00:00
|
|
|
function __construct() {
|
|
|
|
$this->SetLanguage("en", "lib/phpmailer/language/");
|
2013-04-16 12:40:04 +00:00
|
|
|
|
2013-03-22 20:25:12 +00:00
|
|
|
if (SMTP_HOST) {
|
2013-04-16 12:40:04 +00:00
|
|
|
$pair = explode(":", SMTP_HOST, 2);
|
2013-03-22 20:25:12 +00:00
|
|
|
$Mailer = "smtp";
|
2013-04-16 12:40:04 +00:00
|
|
|
|
|
|
|
$Host = $pair[0];
|
|
|
|
$Port = $pair[1];
|
|
|
|
|
|
|
|
if (!$Port) $Port = 25;
|
|
|
|
} else {
|
|
|
|
$Host = '';
|
|
|
|
$Port = '';
|
2013-03-22 20:25:12 +00:00
|
|
|
}
|
2013-04-16 12:40:04 +00:00
|
|
|
|
2013-03-23 05:20:16 +00:00
|
|
|
|
2013-03-22 20:25:12 +00:00
|
|
|
//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;
|
2013-03-23 05:20:16 +00:00
|
|
|
$this->IsHTML($altbody != '');
|
2013-03-22 20:25:12 +00:00
|
|
|
$rc=$this->send();
|
|
|
|
return $rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-23 05:20:16 +00:00
|
|
|
?>
|