1: <?php
2: /*
3: You may not change or alter any portion of this comment or credits
4: of supporting developers from this source code or any supporting source code
5: which is considered copyrighted (c) material of the original comment or credit authors.
6:
7: This program is distributed in the hope that it will be useful,
8: but WITHOUT ANY WARRANTY; without even the implied warranty of
9: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: */
11:
12: /**
13: * Xoops MultiMailer Base Class
14: *
15: * Mailer Class.
16: *
17: * At the moment, this does nothing but send email through PHP's "mail()" function,
18: * but it has the abiltiy to do much more.
19: *
20: * If you have problems sending mail with "mail()", you can edit the member variables
21: * to suit your setting. Later this will be possible through the admin panel.
22: *
23: * @todo Make a page in the admin panel for setting mailer preferences.
24: *
25: * PHP 5.3
26: *
27: * @category Xoops\Class\Cache\MultiMailer
28: * @package MultiMailer
29: * @author Author: Jochen Bünnagel <job@buennagel.com>
30: * @copyright 2013 XOOPS Project (http://xoops.org)
31: * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
32: * @version $Id$
33: * @link http://xoops.org
34: * @since 2.6.0
35: */
36: class XoopsMultiMailer extends PHPMailer
37: {
38: /**
39: * 'from' address
40: *
41: * @var string from address
42: */
43: public $From = '';
44:
45: /**
46: * 'from' name
47: *
48: * @var string from name
49: */
50: public $FromName = '';
51:
52: // can be 'smtp', 'sendmail', or 'mail'
53: /**
54: * Method to be used when sending the mail.
55: *
56: * This can be:
57: * <li>mail (standard PHP function 'mail()') (default)
58: * <li>smtp (send through any SMTP server, SMTPAuth is supported.
59: * You must set {@link $Host}, for SMTPAuth also {@link $SMTPAuth},
60: * {@link $Username}, and {@link $Password}.)
61: * <li>sendmail (manually set the path to your sendmail program
62: * to something different than 'mail()' uses in {@link $Sendmail})
63: *
64: * @var string type of mailer
65: */
66: public $Mailer = 'mail';
67:
68: /**
69: * set if $Mailer is 'sendmail'
70: *
71: * Only used if {@link $Mailer} is set to 'sendmail'.
72: * Contains the full path to your sendmail program or replacement.
73: *
74: * @var string sendmail configuration
75: */
76: public $Sendmail = '/usr/sbin/sendmail';
77:
78: /**
79: * SMTP Host.
80: *
81: * Only used if {@link $Mailer} is set to 'smtp'
82: *
83: * @var string SMTP host name
84: */
85: public $Host = '';
86:
87: /**
88: * Does your SMTP host require SMTPAuth authentication?
89: *
90: * @var boolean authorized?
91: */
92: public $SMTPAuth = false;
93:
94: /**
95: * Username for authentication with your SMTP host.
96: *
97: * Only used if {@link $Mailer} is 'smtp' and {@link $SMTPAuth} is TRUE
98: *
99: * @var string user name for SMTP authentication
100: */
101: public $Username = '';
102:
103: /**
104: * Password for SMTPAuth.
105: *
106: * Only used if {@link $Mailer} is 'smtp' and {@link $SMTPAuth} is TRUE
107: *
108: * @var string password for smtp authentication
109: */
110: public $Password = '';
111:
112: /**
113: * Constructor
114: */
115: public function __construct()
116: {
117: $xoops = Xoops::getInstance();
118: $this->From = $xoops->getConfig('from');
119: if ($this->From == '') {
120: $this->From = $xoops->getConfig('adminmail');
121: }
122: $this->Sender = $this->From;
123: if ('smtpauth' === $xoops->getConfig('mailmethod')) {
124: $this->Mailer = 'smtp';
125: $this->SMTPAuth = true;
126: $this->Username = $xoops->getConfig('smtpuser');
127: $this->Password = $xoops->getConfig('smtppass');
128: } else {
129: $this->Mailer = $xoops->getConfig('mailmethod');
130: $this->SMTPAuth = false;
131: $this->Sendmail = $xoops->getConfig('sendmailpath');
132: }
133: // TODO: change value type of xoopsConfig 'smtphost' from array to text
134: $smtphost = $xoops->getConfig('smtphost');
135: $this->Host = is_array($smtphost) ? implode(';', $smtphost) : $smtphost;
136: //$this->PluginDir = \XoopsBaseConfig::get('root-path') . '/class/mail/phpmailer/';
137: }
138: }
139: