]> git.wh0rd.org - tt-rss.git/blob - classes/ttrssmailer.php
unify SMTP_HOST and SMTP_PORT as SMTP_SERVER
[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 public $Host;
21 public $Port;
22 public $SMTPAuth=False;
23 public $Username;
24 public $Password;
25
26 function __construct() {
27 $this->SetLanguage("en", "lib/phpmailer/language/");
28
29 if (SMTP_HOST) {
30 $pair = explode(":", SMTP_HOST, 2);
31 $Mailer = "smtp";
32
33 $Host = $pair[0];
34 $Port = $pair[1];
35
36 if (!$Port) $Port = 25;
37 } else {
38 $Host = '';
39 $Port = '';
40 }
41
42
43 //if SMTP_LOGIN is specified, set credentials and enable auth
44 if(SMTP_LOGIN){
45 $SMTPAuth = true;
46 $Username = SMTP_LOGIN;
47 $Password = SMTP_PASSWORD;
48 }
49 }
50 /* @brief a simple mail function to send email using the defaults
51 * This will send an HTML email using the configured defaults
52 * @param $toAddress A string with the recipients email address
53 * @param $toName A string with the recipients name
54 * @param $subject A string with the emails subject
55 * @param $body A string containing the body of the email
56 */
57 public function quickMail ($toAddress, $toName, $subject, $body, $altbody=""){
58 $this->addAddress($toAddress, $toName);
59 $this->Subject = $subject;
60 $this->Body = $body;
61 $this->IsHTML($altbody != '');
62 $rc=$this->send();
63 return $rc;
64 }
65 }
66
67 ?>