|
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 <[email protected]> |
|
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
|
|
|
* @link http://xoops.org |
|
33
|
|
|
* @since 2.6.0 |
|
34
|
|
|
*/ |
|
35
|
|
|
class XoopsMultiMailer extends PHPMailer // for 6.0 \PHPMailer\PHPMailer\PHPMailer |
|
36
|
|
|
{ |
|
37
|
|
|
/** |
|
38
|
|
|
* 'from' address |
|
39
|
|
|
* |
|
40
|
|
|
* @var string from address |
|
41
|
|
|
*/ |
|
42
|
|
|
public $From = ''; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* 'from' name |
|
46
|
|
|
* |
|
47
|
|
|
* @var string from name |
|
48
|
|
|
*/ |
|
49
|
|
|
public $FromName = ''; |
|
50
|
|
|
|
|
51
|
|
|
// can be 'smtp', 'sendmail', or 'mail' |
|
52
|
|
|
/** |
|
53
|
|
|
* Method to be used when sending the mail. |
|
54
|
|
|
* |
|
55
|
|
|
* This can be: |
|
56
|
|
|
* <li>mail (standard PHP function 'mail()') (default) |
|
57
|
|
|
* <li>smtp (send through any SMTP server, SMTPAuth is supported. |
|
58
|
|
|
* You must set {@link $Host}, for SMTPAuth also {@link $SMTPAuth}, |
|
59
|
|
|
* {@link $Username}, and {@link $Password}.) |
|
60
|
|
|
* <li>sendmail (manually set the path to your sendmail program |
|
61
|
|
|
* to something different than 'mail()' uses in {@link $Sendmail}) |
|
62
|
|
|
* |
|
63
|
|
|
* @var string type of mailer |
|
64
|
|
|
*/ |
|
65
|
|
|
public $Mailer = 'mail'; |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* set if $Mailer is 'sendmail' |
|
69
|
|
|
* |
|
70
|
|
|
* Only used if {@link $Mailer} is set to 'sendmail'. |
|
71
|
|
|
* Contains the full path to your sendmail program or replacement. |
|
72
|
|
|
* |
|
73
|
|
|
* @var string sendmail configuration |
|
74
|
|
|
*/ |
|
75
|
|
|
public $Sendmail = '/usr/sbin/sendmail'; |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* SMTP Host. |
|
79
|
|
|
* |
|
80
|
|
|
* Only used if {@link $Mailer} is set to 'smtp' |
|
81
|
|
|
* |
|
82
|
|
|
* @var string SMTP host name |
|
83
|
|
|
*/ |
|
84
|
|
|
public $Host = ''; |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* Does your SMTP host require SMTPAuth authentication? |
|
88
|
|
|
* |
|
89
|
|
|
* @var boolean authorized? |
|
90
|
|
|
*/ |
|
91
|
|
|
public $SMTPAuth = false; |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* Username for authentication with your SMTP host. |
|
95
|
|
|
* |
|
96
|
|
|
* Only used if {@link $Mailer} is 'smtp' and {@link $SMTPAuth} is TRUE |
|
97
|
|
|
* |
|
98
|
|
|
* @var string user name for SMTP authentication |
|
99
|
|
|
*/ |
|
100
|
|
|
public $Username = ''; |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* Password for SMTPAuth. |
|
104
|
|
|
* |
|
105
|
|
|
* Only used if {@link $Mailer} is 'smtp' and {@link $SMTPAuth} is TRUE |
|
106
|
|
|
* |
|
107
|
|
|
* @var string password for smtp authentication |
|
108
|
|
|
*/ |
|
109
|
|
|
public $Password = ''; |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* Constructor |
|
113
|
|
|
*/ |
|
114
|
28 |
|
public function __construct() |
|
115
|
|
|
{ |
|
116
|
28 |
|
parent::__construct(); |
|
117
|
28 |
|
$xoops = Xoops::getInstance(); |
|
118
|
28 |
|
$this->From = $xoops->getConfig('from'); |
|
119
|
28 |
|
if ($this->From == '') { |
|
120
|
28 |
|
$this->From = $xoops->getConfig('adminmail'); |
|
121
|
|
|
} |
|
122
|
28 |
|
$this->Sender = $this->From; |
|
123
|
28 |
|
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
|
28 |
|
$this->Mailer = $xoops->getConfig('mailmethod'); |
|
130
|
28 |
|
$this->SMTPAuth = false; |
|
131
|
28 |
|
$this->Sendmail = $xoops->getConfig('sendmailpath'); |
|
132
|
|
|
} |
|
133
|
|
|
// TODO: change value type of xoopsConfig 'smtphost' from array to text |
|
134
|
28 |
|
$smtphost = $xoops->getConfig('smtphost'); |
|
135
|
28 |
|
$this->Host = is_array($smtphost) ? implode(';', $smtphost) : $smtphost; |
|
136
|
|
|
//$this->PluginDir = \XoopsBaseConfig::get('root-path') . '/class/mail/phpmailer/'; |
|
137
|
28 |
|
} |
|
138
|
|
|
} |
|
139
|
|
|
|