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