From 97e6f95aacb35d5d83be11af1b9b14302a373cd7 Mon Sep 17 00:00:00 2001 From: Tim van Dijen <tvdijen@gmail.com> Date: Tue, 22 Aug 2017 20:04:13 +0200 Subject: [PATCH] Add sendmail_from option --- config-templates/config.php | 5 +++++ www/errorreport.php | 15 +++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/config-templates/config.php b/config-templates/config.php index f25f30b1e..b9e9e0043 100644 --- a/config-templates/config.php +++ b/config-templates/config.php @@ -54,6 +54,11 @@ $config = array( 'technicalcontact_name' => 'Administrator', 'technicalcontact_email' => 'na@example.org', + /* + * Sender email should use the same domain as your application domain to prevent SPF record filtering + */ + //'sendmail_from' => 'no-reply@example.org', + /* * The timezone of the server. This option should be set to the timezone you want * SimpleSAMLphp to report the time in. The default is to guess the timezone based diff --git a/www/errorreport.php b/www/errorreport.php index d99f313b9..569db4199 100644 --- a/www/errorreport.php +++ b/www/errorreport.php @@ -101,10 +101,21 @@ $email = trim($email); // check that it looks like a valid email address if (!preg_match('/\s/', $email) && strpos($email, '@') !== false) { $replyto = $email; - $from = $email; } else { $replyto = null; - $from = 'no-reply@simplesamlphp.org'; +} + +$from = $config->getString('sendmail_from', null); +if ($from === null || $from === '') { + $from = ini_get('sendmail_from'); + if ($from === '' || $from === false) { + $from = 'no-reply@example.org'; + } +} + +// If no sender email was configured at least set some relevant from address +if ($from === 'no-reply@example.org' && $replyto !== null) { + $from = $replyto; } // send the email -- GitLab