]>
git.wh0rd.org - tt-rss.git/blob - classes/mailer.php
3 // TODO: support HTML mail (i.e. MIME messages)
5 private $last_error = "Unable to send mail: check local configuration.";
7 function mail($params) {
10 $subject = $params["subject"];
11 $message = $params["message"];
12 $message_html = $params["message_html"];
13 $from = $params["from"] ?
$params["from"] : SMTP_FROM_NAME
. " <" . SMTP_FROM_ADDRESS
. ">";
14 $additional_headers = $params["headers"] ?
$params["headers"] : [];
16 $headers[] = "From: $from";
18 Logger
::get()->log("Sending mail from $from to $to [$subject]: $message");
20 // HOOK_SEND_MAIL plugin instructions:
21 // 1. return 1 or true if mail is handled
22 // 2. return -1 if there's been a fatal error and no further action is allowed
23 // 3. any other return value will allow cycling to the next handler and, eventually, to default mail() function
24 // 4. set error message if needed via passed Mailer instance function set_error()
26 foreach (PluginHost
::getInstance()->get_hooks(PluginHost
::HOOK_SEND_MAIL
) as $p) {
27 $rc = $p->hook_send_mail($this, $params);
29 if ($rc == 1 ||
$rc == -1)
33 return mail($to, $subject, $message, implode("\r\n", array_merge($headers, $additional_headers)));
36 function set_error($message) {
37 $this->last_error
= $message;
40 function error($value) {
41 return $this->last_error
;