From 4279323c6ec35019d813d8c07eec2e7a4d897791 Mon Sep 17 00:00:00 2001 From: "Maximilian Kroth (tMaex.com)" Date: Sun, 15 Feb 2026 15:31:26 +0100 Subject: [PATCH] add option to use SMTP for mails --- ajax/sendMail.json.php | 19 +++++++++++++++++-- config.inc.php.template | 9 +++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/ajax/sendMail.json.php b/ajax/sendMail.json.php index e941240..e101c95 100644 --- a/ajax/sendMail.json.php +++ b/ajax/sendMail.json.php @@ -12,13 +12,28 @@ $mailform = $request['mailform']; $subject = mb_encode_mimeheader($mailform->subject, "UTF-8", "Q"); -$mailer = Mail::factory('mail'); + $headers = array( 'Charset' => 'UTF-8', 'Content-Type' => 'text/plain; charset="UTF-8"', 'From' => $mailform->sender, 'To' => $mailform->recipient, - 'Subject' => $subject); + 'Subject' => $subject +); + +if (!defined('MAIL_HOST')) $mailer = Mail::factory('mail'); +else { + $params = array(); + $params['host'] = MAIL_HOST; + $params['debug'] = true; + if (defined('MAIL_PORT')) $params['port'] = MAIL_PORT; + if (defined('MAIL_AUTH')) $params['auth'] = MAIL_AUTH; + if (defined('MAIL_USERNAME')) $params['username'] = MAIL_USERNAME; + if (defined('MAIL_PASSWORD')) $params['password'] = MAIL_PASSWORD; + + $mailer = Mail::factory('smtp', $params); + $headers['From'] = MAIL_SENDER; +} $retval = array(); diff --git a/config.inc.php.template b/config.inc.php.template index 6565213..29e5c70 100644 --- a/config.inc.php.template +++ b/config.inc.php.template @@ -18,6 +18,15 @@ define('STORE_NTLM_HASH', false); define('PAGETITLE', 'example.com User Admin'); +// Mail configuration +// set MAIL_HOST to use SMTP or don't define it to use mail() + +// define('MAIL_HOST', ''); +// define('MAIL_PORT', 587); +// define('MAIL_AUTH', true); +// define('MAIL_USERNAME', ''); +// define('MAIL_PASSWORD', ''); + define('MAIL_SENDER', 'webteam@example.com'); const MAIL_TEMPLATES = array( 'addUser' => array(