diff options
author | Andrew Dolgov <[email protected]> | 2021-03-03 14:00:18 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2021-03-03 14:00:18 +0300 |
commit | 0730128a97a46054099b59554e891cee99829eaa (patch) | |
tree | 8e77a0f91c4854dd6e658c97284a27c4588b1c2c /classes/mailer.php | |
parent | dbda996a7a04ce96803e045dfaf27d1c577c3f4e (diff) |
add a send test email button to prefs/system
Diffstat (limited to 'classes/mailer.php')
-rw-r--r-- | classes/mailer.php | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/classes/mailer.php b/classes/mailer.php index 968caf54a..564338f69 100644 --- a/classes/mailer.php +++ b/classes/mailer.php @@ -1,8 +1,6 @@ <?php class Mailer { - // TODO: support HTML mail (i.e. MIME messages) - - private $last_error = "Unable to send mail: check local configuration."; + private $last_error = ""; function mail($params) { @@ -39,11 +37,18 @@ class Mailer { $headers = [ "From: $from_combined", "Content-Type: text/plain; charset=UTF-8" ]; - return mail($to_combined, $subject, $message, implode("\r\n", array_merge($headers, $additional_headers))); + $rc = mail($to_combined, $subject, $message, implode("\r\n", array_merge($headers, $additional_headers))); + + if (!$rc) { + $this->set_error(error_get_last()['message']); + } + + return $rc; } function set_error($message) { $this->last_error = $message; + user_error("Error sending mail: $message", E_USER_WARNING); } function error() { |