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

[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 cron is running and run ./ 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 }}
@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 - Low Toner Severity: warning Timestamp: 2018-08-21 15:35:15 Unique-ID: 1381 Rule: Low Toner Faults: #1: sysObjectID = .; sysDescr = KYOCERA Document Solutions Printing System; toner_id = 57; toner_oid = .; toner_descr = TK-174; Alert sent to:

@dented your template doesnt contains any html.

Take a look to 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;">
{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}
{if %faults}
{foreach %faults}
<b>Device:</b> {if %transport == mail} 
<a href="http://librenms/device/device=%hostname/">%hostname</a>
{/if} <br>
<b>Toner:</b> %value.toner_descr<br>
<b>Toner Level:</b> %value.toner_current<br>
{if %location}
<b>Location:</b> %location<br>
<b>Location:</b> LOCATION NOT DEFINED YET!!<br>
<b>Uptime:</b> %uptime_long<br>
<b>Duration:</b> %elapsed<br>
{if %description}
<b>Description:</b> %description<br>
{if %Features}
<b>Features:</b> %features<br>
{if %Purpose}
<b>Purpose:</b> %purpose<br>
{if %Notes}
<b>Notes:</b> %notes<br>
<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>
<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.


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 
 @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>
{{ $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>
<b>Location:</b> LOCATION NOT DEFINED YET!!<br>
<b>Uptime:</b> {{ $alert->uptime_long }}<br>
<b>Duration:</b> {{ $alert->elapsed }}<br>
 @if ($alert->description) 
<b>Description:</b> {{ $alert->description }}<br>
 @if ($alert->Features) 
<b>Features:</b> {{ $alert->features }}<br>
 @if ($alert->Purpose) 
<b>Purpose:</b> {{ $alert->purpose }}<br>
 @if ($alert->Notes) 
<b>Notes:</b> {{ $alert->notes }}<br>
<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>
<b>Alerts sent to:</b>  @foreach ($alert->contacts as $key => $value){{ $value }} <{{ $key }}>  @endforeach  

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.