HTML Email Transport

====================================

Component Version
LibreNMS 1.42.01-21-g32f8a297e
DB Schema 258
PHP 7.0.30-0+deb9u1
MySQL 10.1.26-MariaDB-0+deb9u1
RRDTool 1.6.0
SNMP NET-SNMP 5.7.3
====================================

[OK] Composer Version: 1.7.1
[OK] Dependencies up-to-date.
[OK] Database connection successful
[OK] Database schema correct
[WARN] Your install is over 24 hours out of date, last update: Thu, 09 Aug 2018 21:43:14 +0000
[FIX] Make sure your daily.sh cron is running and run ./daily.sh by hand to see if there are any errors.
(Yes I need to sort this out. Just have to get some paperwork signed off on so I can bypass the proxy for updating)

So I cannot get the Email transport to send an email formatted with HTML.

here is the template

{{ $alert->Title }}
@if ($alert->state == 1) {{ $alert->severity }} @endif @if ($alert->state == 2) Low Toner Acknowledged @endif @if ($alert->state == 3) Low Toner Recovering @endif @if ($alert->state == 0) Toner Replaced @endif


@if ($alert->faults) @foreach ($alert->faults as $key => $value) Device: @if ($alert->transport == mail) @else {{ $alert->hostname }} @endif
Toner: {{ $value['toner_descr'] }}
Toner Level: {{ $value['toner_current'] }}
@if ($alert->location) Location: {{ $alert->location }}
@else Location: LOCATION NOT DEFINED YET!!
@endif Uptime: {{ $alert->uptime_long }}
Duration: {{ $alert->elapsed }}
@if ($alert->description) Description: {{ $alert->description }}
@endif @if ($alert->Features) Features: {{ $alert->features }}
@endif @if ($alert->Purpose) Purpose: {{ $alert->purpose }}
@endif @if ($alert->Notes) Notes: {{ $alert->notes }}
@endif Device: {{ $value['sysDescr'] }}



@endforeach @endif
Alerts sent to: @foreach ($alert->contacts as $key => $value){{ $value }} <{{ $key }}> @endforeach

As you can see I have HTML enabled. Any thoughts ?

The email comes out looking like (sorry it would only let me post 1 screenshot)

hpe printer Alert for device 192.200.201.17 - Low Toner Severity: warning Timestamp: 2018-08-21 15:35:15 Unique-ID: 1381 Rule: Low Toner Faults: #1: sysObjectID = .1.3.6.1.4.1.1347.41; sysDescr = KYOCERA Document Solutions Printing System; toner_id = 57; toner_oid = .1.3.6.1.2.1.43.11.1.1.9.1.1; toner_descr = TK-174; Alert sent to:

@dented your template doesnt contains any html.

Take a look to https://docs.librenms.org/#Alerting/Templates/ at the HTML Templates section.

1 Like

Doh. Thank you I was sure it had some in there and has been stripped out in my attempt to get it working.

div style="font-family:Helvetica;">
<b>%Title<br>
{if %state == 1}<span style="color:DarkOrchid;">%severity{/if}
{if %state == 2}<span style="color:goldenrod;">Low Toner Acknowledged{/if}
{if %state == 3}<span style="color:DarkKhaki;">Low Toner Recovering{/if}
{if %state == 0}<span style="color:green;">Toner Replaced{/if}
</span></b>
<br><br>
{if %faults}
{foreach %faults}
<b>Device:</b> {if %transport == mail} 
<a href="http://librenms/device/device=%hostname/">%hostname</a>
{else}
%hostname
{/if} <br>
<b>Toner:</b> %value.toner_descr<br>
<b>Toner Level:</b> %value.toner_current<br>
{if %location}
<b>Location:</b> %location<br>
{else}
<b>Location:</b> LOCATION NOT DEFINED YET!!<br>
{/if}
<b>Uptime:</b> %uptime_long<br>
<b>Duration:</b> %elapsed<br>
{if %description}
<b>Description:</b> %description<br>
{/if}
{if %Features}
<b>Features:</b> %features<br>
{/if}
{if %Purpose}
<b>Purpose:</b> %purpose<br>
{/if}
{if %Notes}
<b>Notes:</b> %notes<br>
{/if}
<b>Device: </b>%value.sysDescr<br><br>
<img src="http://librenms/graph.php?width=459&height=213&lazy_w=552&from=end-30d&device=%value.device_id&type=device_toner&legend=yes"><br><br>
{/foreach}
{/if}
<br>
<B>Alerts sent to:</b> {foreach %contacts}%value <%key> {/foreach} <br>

There that is what i have. Yes

So it is working now?

No, still the same issue. The alert is coming out as plain text.

Using your template with html enabled works for me. What are you seeing in the mail that comes through?

Maybe your email client doesn’t display HTML.
Maybe because of the origin of the mail

The thing is I have no issue with any of my other servers. Html emails work fine.

They all use the same mail relay.

Screenshot_20180827-214923_Gmail|281x500

Might be worth converting the template to the new format but I’ve used the one you gave and it worked ok.

I also tried that.

<div style="font-family:Helvetica;">
<b>{{ $alert->Title }}<br>
 @if ($alert->state == 1) <span style="color:DarkOrchid;">{{ $alert->severity }} @endif 
 @if ($alert->state == 2) <span style="color:goldenrod;">Low Toner Acknowledged @endif 
 @if ($alert->state == 3) <span style="color:DarkKhaki;">Low Toner Recovering @endif 
 @if ($alert->state == 0) <span style="color:green;">Toner Replaced @endif 
</span></b>
<br><br>
 @if ($alert->faults) 
 @foreach ($alert->faults as $key => $value)
<b>Device:</b>  @if ($alert->transport == mail)  
<a href="http://librenms/device/device={{ $alert->hostname }}/">{{ $alert->hostname }}</a>
 @else 
{{ $alert->hostname }}
 @endif  <br>
<b>Toner:</b> {{ $value['toner_descr'] }}<br>
<b>Toner Level:</b> {{ $value['toner_current'] }}<br>
 @if ($alert->location) 
<b>Location:</b> {{ $alert->location }}<br>
 @else 
<b>Location:</b> LOCATION NOT DEFINED YET!!<br>
 @endif 
<b>Uptime:</b> {{ $alert->uptime_long }}<br>
<b>Duration:</b> {{ $alert->elapsed }}<br>
 @if ($alert->description) 
<b>Description:</b> {{ $alert->description }}<br>
 @endif 
 @if ($alert->Features) 
<b>Features:</b> {{ $alert->features }}<br>
 @endif 
 @if ($alert->Purpose) 
<b>Purpose:</b> {{ $alert->purpose }}<br>
 @endif 
 @if ($alert->Notes) 
<b>Notes:</b> {{ $alert->notes }}<br>
 @endif 
<b>Device: </b>{{ $value['sysDescr'] }}<br><br>
<img src="http://librenms/graph.php?width=459&height=213&lazy_w=552&from=end-30d&device={{ $value['device_id'] }}&type=device_toner&legend=yes"><br><br>
 @endforeach 
 @endif 
<br>
<b>Alerts sent to:</b>  @foreach ($alert->contacts as $key => $value){{ $value }} <{{ $key }}>  @endforeach  
</div>

No go.

I feel like it is something to do with my setup / a config file.

Any suggestions on where to look?

All going now. Not sure exactly what was wrong, but thanks for the help.