This is a fresh install with PHP 7.3.1, latest LibreNMS. Email alerts fail with the following error:
Could not issue critical alert for rule ‘Service up/down’ to transport ‘mail’ Error: <strong>Invalid address: (setFrom) [email protected]</strong><br />
Also, I can’t add Slack transport because I get an Invalid URL error when I try to submit the form. I suspect that this is related to PHP 7.3 and Laravel, I also encountered this bug: WebUI: nginx + php 7.3 Error in: laravel/framework/src/Illuminate/Database/Query/Builder.php:1229 but the patch solved it.
[root@shelter /opt/librenms]# ./validate.php
Component |
Version |
LibreNMS |
1.48.1-22-gd2af4bef4 |
DB Schema |
2019_01_16_195644_add_vrf_id_and_bgpLocalAs (131) |
PHP |
7.3.1 |
MySQL |
10.3.11-MariaDB-log |
RRDTool |
1.7.0 |
SNMP |
NET-SNMP 5.7.3 |
====================================
[OK] Composer Version: 1.8.3
[OK] Dependencies up-to-date.
[OK] Database connection successful
[OK] Database schema correct
[root@shelter /opt/librenms]#
LibreNMS doesn’t support php 7.3 yet officially. 5.6 and 7.0 are unsupported now so hopefully support for 7.3 will come soon. Thanks for the reports.
Slack validation is now resolved, I can enter the webhook URL (deleted from the screenshot) and there’s no validation error, also the transport itself is OK, I’m getting notifications through slack.
Email alerting is still broken after Laravel update (#9800)
Updating to latest codebase OK
Updating Composer packages OK
Updated from 2f8964ce2 to d23ab0693 OK
Updating SQL-Schema OK
Updating submodules OK
Cleaning up DB OK
Fetching notifications OK
Caching PeeringDB data OK
====================================
Component | Version
--------- | -------
LibreNMS | 1.48.1-46-gd23ab0693
DB Schema | 2019_01_16_195644_add_vrf_id_and_bgpLocalAs (131)
PHP | 7.3.1
MySQL | 10.3.11-MariaDB-log
RRDTool | 1.7.0
SNMP | NET-SNMP 5.7.3
====================================
[OK] Composer Version: 1.8.4
[OK] Dependencies up-to-date.
[OK] Database connection successful
[OK] Database schema correct
Works for me when I try it… Anything in your librenms.log?
Nothing in librenms.log. This is very strange, I edited send_mail() in functions.php to get some debug info.
foreach (parse_email($config['email_from']) as $from => $from_name) {
error_log($from);
error_log($from_name);
$mail->setFrom($from, $from_name);
error_log("setFrom() OK");
}
...
} catch (phpmailerException $e) {
error_log("PHPMailer() exception");
return $e->errorMessage();
} catch (Exception $e) {
return $e->getMessage();
}
}
return "No contacts found";
}
And the result is:
[13-Feb-2019 18:15:08] WARNING: [pool librenms] child 30611 said into stderr: "NOTICE: PHP message: [email protected]"
[13-Feb-2019 18:15:08] WARNING: [pool librenms] child 30611 said into stderr: "NOTICE: PHP message: DNS123 Alerting Service"
[13-Feb-2019 18:15:09] WARNING: [pool librenms] child 30611 said into stderr: "NOTICE: PHP message: PHPMailer() exception"
According to composer the installed PHPMailer version is v5.2.27
I have: phpmailer/phpmailer v5.2.27
You could check the exception to see what it is… (presumably Invalid address)
According to https://github.com/PHPMailer/PHPMailer
PHPMailer 5.2 (which is compatible with PHP 5.0 - 7.0) is no longer being supported for feature updates, and will only be receiving security updates from now on. You will find the latest version of 5.2 in the 5.2-stable branch, and future versions of 5.2 will be tagged with 5.2.x version numbers, so existing Composer configs should remain working. If you’re using PHP 5.5 or later, we recommend you make the necessary changes to switch to the 6.0 release.
The 5.2 branch will not receive security updates after December 31st 2018.
There are backward incompatible changes with 6.0, it doesn’t work out of the box, I just upgraded it locally. The setFrom() error is gone, now I have ‘general error’, currently investigating what needs to be changed.
Yep, upgrading did it. Works perfectly fine. 3 lines of code. There’s something in PHP 7.3 which breaks validations like the Laravel upgrade solved the URL validation error with Slack transport.
composer.json
diff --git a/composer.json b/composer.json
index 699d1cd94..4ddace53d 100644
--- a/composer.json
+++ b/composer.json
@@ -31,7 +31,7 @@
"ext-mbstring": "*",
"laravel/laravel": "5.7.*",
"ezyang/htmlpurifier": "^4.8",
- "phpmailer/phpmailer": "^5.2.21",
+ "phpmailer/phpmailer": "~6.0",
"slim/slim": "^2.6",
"easybook/geshi": "^1.0.8",
"amenadiel/jpgraph": "^3.6",
includes/alerts.inc.php
diff --git a/includes/alerts.inc.php b/includes/alerts.inc.php
index f8c93bf7a..6e904c6ac 100644
--- a/includes/alerts.inc.php
+++ b/includes/alerts.inc.php
@@ -28,6 +28,7 @@ use LibreNMS\Alert\AlertData;
use LibreNMS\Alerting\QueryBuilderParser;
use LibreNMS\Authentication\LegacyAuth;
use LibreNMS\Alert\AlertUtil;
+use PHPMailer\PHPMailer\PHPMailer;
/**
* @param $rule
includes/functions.inc.php
diff --git a/includes/functions.php b/includes/functions.php
index bc8d4f466..f0229deca 100644
--- a/includes/functions.php
+++ b/includes/functions.php
@@ -25,6 +25,7 @@ use LibreNMS\Util\IPv4;
use LibreNMS\Util\IPv6;
use LibreNMS\Util\MemcacheLock;
use Symfony\Component\Process\Process;
+use PHPMailer\PHPMailer\PHPMailer;
if (!function_exists('set_debug')) {
/**
Great work, can you send a pull request?
@murrant sure, will do that soon. I wanted to know the cause before submitting a PR, so here it is:
http://php.net/manual/en/migration73.other-changes.php
The PCRE extension has been upgraded to PCRE2, which may cause minor behavioral changes (for instance, character ranges in classes are now more strictly interpreted), and augments the existing regular expression syntax.
preg_quote() now also escapes the ‘#’ character.
1 Like