I’ve got the mail settings all setup for smtp in the global alert settings with our smtp server, the send alerts to default contact turned off, the alert transport type is set as mail and set to send to a specific email address however librenms does not seem to be sending the alert emails. I see the alerts based on the rules I have setup, but no email notification. I didn’t edit the mail.php file and only configured the smtp settings on the web UI. Am I missing something?
Any help is appreciated. Thx
Have you tried the testing docs for alerting? Testing - LibreNMS Docs
yep. here’s the result
“select * from users
where exists (select * from roles
inner join assigned_roles
on roles
.id
= assigned_roles
.role_id
where users
.user_id
= assigned_roles
.entity_id
and assigned_roles
.entity_type
= ‘App\Models\User’ and name
in (‘admin’, ‘global-read’) and (assigned_roles
.scope
is null) and (roles
.scope
is null)) and not email
= ‘’” // vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:3919
Issuing Alert-UID #1949/1:
:: Transport mail => OK
still not getting the email alert
If you edit LibreNMS/Util/Mail.php
on line 118 and change $mail->SMTPDebug = 0;
to $mail->SMTPDebug = 1;
Then re-run the test.
Once done, run git checkout LibreNMS/Util/Mail.php
no change. here’s the full debug result from test-altert.php
./scripts/test-alert.php -r 1 -h 49 -d
SQL[SELECT alerts.id, alerts.alerted, alerts.device_id, alerts.rule_id, alerts.state, alerts.note, alerts.info FROM alerts WHERE alerts.device_id = 49 && alerts.rule_id = 1 [] 0.28ms]
SQL[SELECT alert_log.id,alert_log.rule_id,alert_log.device_id,alert_log.state,alert_log.details,alert_log.time_logged,alert_rules.rule,alert_rules.severity,alert_rules.extra,alert_rules.name,alert_rules.query,alert_rules.builder,alert_rules.proc FROM alert_log,alert_rules WHERE alert_log.rule_id = alert_rules.id && alert_log.device_id = ? && alert_log.rule_id = ? && alert_rules.disabled = 0 ORDER BY alert_log.id DESC LIMIT 1 [49,1] 0.39ms]
SQL[SELECT DISTINCT a.* FROM alert_rules a
LEFT JOIN alert_device_map d ON a.id=d.rule_id AND (a.invert_map = 0 OR a.invert_map = 1 AND d.device_id = ?)
LEFT JOIN alert_group_map g ON a.id=g.rule_id AND (a.invert_map = 0 OR a.invert_map = 1 AND g.group_id IN (SELECT DISTINCT device_group_id FROM device_group_device WHERE device_id = ?))
LEFT JOIN alert_location_map l ON a.id=l.rule_id AND (a.invert_map = 0 OR a.invert_map = 1 AND l.location_id IN (SELECT DISTINCT location_id FROM devices WHERE device_id = ?))
LEFT JOIN devices ld ON l.location_id=ld.location_id AND ld.device_id = ?
LEFT JOIN device_group_device dg ON g.group_id=dg.device_group_id AND dg.device_id = ?
WHERE a.disabled = 0 AND (
(d.device_id IS NULL AND g.group_id IS NULL AND l.location_id IS NULL)
OR (a.invert_map = 0 AND (d.device_id=? OR dg.device_id=? OR ld.device_id=?))
OR (a.invert_map = 1 AND (d.device_id != ? OR d.device_id IS NULL) AND (dg.device_id != ? OR dg.device_id IS NULL) AND (ld.device_id != ? OR ld.device_id IS NULL))
) [49,49,49,49,49,49,49,49,49,49,49] 1.16ms]
SQL[SELECT * FROM devices WHERE (devices.device_id = ?) AND (devices.status = 0 && (devices.disabled = 0 && devices.ignore = 0)) = 1 AND devices.status_reason = “icmp” [49] 0.35ms]
SQL[select realname
, email
from users
where not email
= ? and (exists (select * from devices
inner join devices_perms
on devices
.device_id
= devices_perms
.device_id
where users
.user_id
= devices_perms
.user_id
and devices_perms
.device_id
in (?))) [“”,49] 0.5ms]
“select * from users
where exists (select * from roles
inner join assigned_roles
on roles
.id
= assigned_roles
.role_id
where users
.user_id
= assigned_roles
.entity_id
and assigned_roles
.entity_type
= ‘App\Models\User’ and name
in (‘admin’, ‘global-read’) and (assigned_roles
.scope
is null) and (roles
.scope
is null)) and not email
= ‘’” // vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:3919
SQL[select realname
, email
from users
where exists (select * from roles
inner join assigned_roles
on roles
.id
= assigned_roles
.role_id
where users
.user_id
= assigned_roles
.entity_id
and assigned_roles
.entity_type
= ? and name
in (?, ?) and (assigned_roles
.scope
is null) and (roles
.scope
is null)) and not email
= ? [“App\Models\User”,“admin”,“global-read”,“”] 0.5ms]
SQL[select * from devices
where device_id
= ? limit 1 [49] 0.36ms]
SQL[select * from devices_attribs
where devices_attribs
.device_id
= ? and devices_attribs
.device_id
is not null [49] 0.26ms]
SQL[select * from device_perf
where device_perf
.device_id
= ? and device_perf
.device_id
is not null order by timestamp
desc limit 1 [49] 0.29ms]
SQL[select * from alert_templates
where exists (select * from alert_template_map
where alert_templates
.id
= alert_template_map
.alert_templates_id
and alert_rule_id
= ?) limit 1 [1] 0.29ms]
SQL[select * from alert_templates
where name
= ? limit 1 [“Default Alert Template”] 0.18ms]
Reporting disabled by user setting
Issuing Alert-UID #1957/1:
SQL[SELECT rule_id
FROM alerts
WHERE id
=? [485] 0.19ms]
SQL[SELECT b.transport_id, b.transport_type, b.transport_name FROM alert_transport_map AS a LEFT JOIN alert_transports AS b ON b.transport_id=a.transport_or_group_id WHERE a.target_type=‘single’ AND a.rule_id=? UNION DISTINCT SELECT d.transport_id, d.transport_type, d.transport_name FROM alert_transport_map AS a LEFT JOIN alert_transport_groups AS b ON a.transport_or_group_id=b.transport_group_id LEFT JOIN transport_group_transport AS c ON b.transport_group_id=c.transport_group_id LEFT JOIN alert_transports AS d ON c.transport_id=d.transport_id WHERE a.target_type=‘group’ AND a.rule_id=? [1,1] 0.4ms]
:: Transport mail => SQL[select * from alert_transports
where alert_transports
.transport_id
= ? limit 1 [2] 0.23ms]
Attempting to email Alert for device 10.110.16.37 - Device Down! Due to no ICMP response. to: [email protected]
OKSQL[insert into eventlog
(reference
, type
, datetime
, severity
, message
, username
, device_id
) values (?, ?, ?, ?, ?, ?, ?) [null,“alert”,“2023-12-15 23:33:19”,0,“Issued critical alert for rule ‘Device Down! Due to no ICMP response.’ to transport ‘mail’”,“”,49] 0.27ms]
Can you share your mail config (feel free to obfuscate the details). the change I said to make should have spat some debug info out when trying smtp like this:
librenms@utils:~$ ./scripts/test-alert.php -r 4 -h 4
Issuing Alert-UID #56/1:
:: Transport mail => 2023-12-15 23:47:28 SMTP ERROR: Failed to connect to server: Connection refused (111)
2023-12-15 23:47:28 SMTP Error: Could not connect to SMTP host. Failed to connect to server
OK
It could also mean that mail is being accepted via the mail server so have you checked your smtp logs?
Have you made sure the from address and name is valid in Settings → Alerting → Email Options?
I’ve tried multiple valid email address’ and even tried a gmail smtp server with no luck
Is your install up to date?
Honestly, because it’s not showing any debug it must not even be getting to trying to send mail via smtp if you have made the change to that file that I mentioned?
yep. I even ran the ./daily.sh to make sure it was up to date. I did build this server from the ovf template instead of from scratch. Maybe I’ll try building a new one from a fresh install
What’s the output of validate?
===========================================
Component | Version |
---|---|
LibreNMS | 23.11.0 (2023-11-17T02:57:41+00:00) |
DB Schema | 2023_11_04_125846_packages_increase_name_column_length (273) |
PHP | 8.1.2-1ubuntu2.14 |
Python | 3.10.12 |
Database | MariaDB 10.6.12-MariaDB-0ubuntu0.22.04.1 |
RRDTool | 1.7.2 |
SNMP | 5.9.1 |
=========================================== |
[OK] Composer Version: 2.6.6
[OK] Dependencies up-to-date.
[OK] Database connection successful
[OK] Database Schema is current
[OK] SQL Server meets minimum requirements
[OK] lower_case_table_names is enabled
[OK] MySQL engine is optimal
[OK] Database and column collations are correct
[OK] Database schema correct
[OK] MySQl and PHP time match
[OK] Active pollers found
[OK] Dispatcher Service is enabled
[OK] Locks are functional
[OK] Python wrapper cron entry is not present
[OK] Redis is unavailable
[OK] rrdtool version ok
[OK] Connected to rrdcached
That’s not showing the file change I said to make, are you sure you edited LibreNMS/Util/Mail.php
?
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.