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