What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

How can I send custom HTML email notifications?

Votes:

0

With recent versions, the customized HTML email notifications have been removed from PRTG. But I need that feature! Is there any way to bring it back?

custom-html email-notifications emails html notifications placeholders prtg

Created on Jan 28, 2016 11:29:42 AM by  Stephan Linke [Paessler Support]

Last change on Feb 3, 2016 7:36:50 AM by  Stephan Linke [Paessler Support]



40 Replies

Accepted Answer

Votes:

5

This article applies to PRTG Network Monitor 15.4.21 or later

Custom HTML Email Notifications

Recently, we changed the way PRTG handles notification emails and simplified the approach so there is only one email template and the option to deliver plain text emails. For most of our customers this will be sufficient. But what about customers that have multiple clients and need customized notifications, languages, logos and layouts?

That's where this script can help. It allows you to create a template file structure with, for example, placeholders, graphs, and custom company logos. It uses a folder called custom (depending on the version, it must first be created manually) within the new \mailtemplates subfolder as of PRTG version 15.4.21. It also supports the use of PRTG groups as well as single email addresses. If PRTG groups are used, you can also decide if only the users primary addresses or every mail configured will be used.

Features

  • Template based HTML mailing
  • Custom logos for each template folder
  • Various placeholders including live graph and sensor stats for the email body and the subject
  • Primary and secondary email servers as fallback (including encrypted password storage)
  • Send emails directly to PRTG user groups without having to worry about their members
  • Send emails to all notification contacts of a user or only the primary one
  • Send emails to separate email addresses (separated by comma)
  • Email address sanity check (duplicate removal and syntactical check)
  • Verbose logging for error detection
  • Use different priorities

Note: This script and its functionality have been tested under PowerShell 4.0. Please make sure it is installed on the PRTG core server or remote probe system, depending on where you use the script.


How Do I Install the Script?

  1. Execute Set-ExecutionPolicy RemoteSigned in a PowerShell (x86) with administrative privileges on the PRTG core server or the remote probe system, depending on where the script is.
  2. Copy the script (located at the end of this reply) to
    C:\Program Files (x86)\PRTG Network Monitor\Notifications\EXE
  3. Modify the script parameters according to your environment. Enter, for example, email server addresses, paths, and account names.
  4. Call the script with the parameter -SetupPasswords. It will ask for the primary and secondary email server passwords. They are stored encrypted inside the same directory.
  5. Create a structure for your template folders under
    C:\Program Files (x86)\PRTG Network Monitor\webroot\mailtemplates\custom
    (For details, see appendix figure 1, template structure.)

So much for the basic installation. Now you can create a new notification with the following parameters: -SensorID %sensor -Recipients @("[email protected]","[email protected]") -prtgGroup "PRTG Users" -TemplateFolder "TemplateA" -Template "simple" -From "[email protected]" -Subject "[sensorPARENTDEVICE] [sensorNAME] Sensor is in sensorSTATUSTEXT state." -Priority "High" (can be low, normal or high. Default is high) -Placeholders @("Team","www.test.com") -PrimaryOnly

The script will now send mails to [email protected] and [email protected] as well as to the members of the PRTG user group PRTG Users. It will use the TemplateA folder and the simple.htm template located within that folder

Is There any Way I Can Test if the Script Is Working Properly?

The script has the verbose switch enabled by default (line 100). If everything is configured correctly, run the script on a command line with the parameters above, modified to your environment. It will look somewhat like this: HTMLNotify console output

The script is pretty chatty, so if something goes wrong, you should directly see the problem.

What About My Passwords? Are They Stored in Files?

Yes, your email server passwords will be stored in two encrypted files. The encryption is done with a separate key, so it is not bound to your user account and can be executed with every user account on the PRTG server. Make sure that only this very user account is allowed to read the key files. This will make your passwords be safer instead of just saving them as clear text.

How Do my Templates Have to Look? Can I Use Placeholders and Graphs?

There are multiple placeholders that you can use within the HTML file itself and the subject of the email address. They will be replaced automatically. Note that there are two types of placeholders:

  • Always present placeholders, taken from PRTG
  • Custom placeholders that you can pass via parameters.

The table itself can be found in the appendix, figure 2. You can use, for example, the current live graph, sensor stats, and messages. As for the additional parameters, they are passed to the script like this:

-Placeholders @("Tech Support Team", "https://www.paessler.com")

Within the template, they can be placed like this:


Dear {0},\\
<br /><br />\\
Please have a look at {1} - Thanks!\\
\\
Yours truly,
PRTG

...using numbers (starting at 0) encapsuled in curly brackets. After replacing, it will look somewhat like this:


Dear Tech Support Team,

Please have a look at https://www.paessler.com - Thanks!

Yours truly, PRTG


Note: The amount of placeholders in the template must match the placeholders passed to the script. Otherwise, you might get unexpected results.


How Does the Logo Placement Work Exactly?

Within the templates folder (or their subfolders), there has to be a file called logo.png that represents the template folder (for example, a customer's logo). If no logo is found in either folder, the Paessler logo will be used.

Do You Have an Example of a Filled HTML Template?

Please see appendix, figure 3, for a filled HTML template. Note that the template is just an example. Design it as you like. An example source code can be found over at pastebin: http://pastebin.com/k1mGBujz (courtesy of advancedrei)

Are There Schematics so I Can See Which Steps the Scripts Actually Take?

With large scripts comes great complexity. You can find the flowchart for the script in the appendix, figure 5.

Disclaimer

This script underwent testing, although we cannot make sure that all scenarios are covered. Usually, it is provided "as is". However, if you find any bugs or have improvements, please do not hesitate to share!

Appendix

1. Template Structure

FolderContent
TemplateAsimple.htm
detail.htm
temperatures.htm
logo.png
TemplateBdatabases.htm
temperature.htm
logo.png

2. Placeholders

PlaceholderReplaced by
miscLOGOThe template logo that resides in the template folder with HTML image tag.
sensorNAMEThe name of the sensor
sensorTYPEThe sensor type
sensorLIVEGRAPHCurrent live graph as HTML image tag
sensorSTATECOLORThe current state color, in hex form (#dedede)
sensorSTATEICONThe sensors current state icon (will be attached automatically)
sensorINTERVALThe current sensor interval
sensorPARENTGROUPThe sensors parent group
sensorPARENTDEVICEThe sensors parent device
sensorPARENTDEVICEIDThe sensors parent device ID
sensorLASTVALUEThe sensors last value
sensorLASTMESSAGEThe sensors last message
sensorSTATUSTEXTThe current status text of the sensor
sensorSTATUSIDThe status ID of the sensor
sensorLASTUPThe sensors last up time
sensorLASTDOWNThe sensors last down time
sensorLASTCHECKThe last check of the sensor
sensorUPTIMEUptime value of the sensor in percent
sensorUPTIMETIMEUptime in friendly format (e.g. 100 days)
sensorDOWNTIMEDowntime in percent
sensorDOWNTIMETIMEDowntime in friendly format
sensorUPDOWNTOTALCoverage in friendly format
sensorUPDOWNSINCECreation date of the sensor?
sensorURLThe URL of the sensor
deviceURLThe URL of its parent device.

3. A Filled Notification

HTMLNotify - a mailtemplate with variables filled

4. The HTMLNotify Script

Source at GitHub

5. Schematics

Schematics of HTMLNotify

Created on Jan 28, 2016 12:39:15 PM by  Stephan Linke [Paessler Support]

Last change on Nov 19, 2018 7:33:15 AM by  Luciano Lingnau [Paessler]



Votes:

0

I'm trying to use the PRTG placeholders in my custom HTML email template but they don't work. All i see in the email it the placeholder text (e.g %probe, %history %systemdatetime, etc...). Is there a special format needed?

snippet from my template: <td> <br><h3>History</h3>%history<br> </td>

Thanks

Created on Apr 25, 2016 3:40:16 PM



Votes:

0

Can you post your parameter field of the EXE file (from the notification)? Is it possible that you didn't hand it over via -placeholders?

Created on Apr 26, 2016 6:17:45 AM by  Stephan Linke [Paessler Support]



Votes:

0

Wow this is sooooo complex. We use an email to SMS service so the message we get on the phone is just full of this at the beginning;

Sensor:

Almost useless. There isn't a simpler way to cut down the nonsense emailed to an sms gateway?

Joe

Created on Jul 31, 2016 10:34:52 PM



Votes:

0

You could set the mail to text only in the notification options, then you can configure an entirely custom text :)

Created on Aug 1, 2016 6:26:37 AM by  Stephan Linke [Paessler Support]



Votes:

0

Have been able to get the script working via powershell, passing the parameters and receiving the email with the correct template. But when associating the powershell script in the notification settings and putting the same parameters under execute program it is not working. Have tried the execute program option to run the program under the local admin account and still didn't work. Is there a way for the script to generate a log to troubleshooting why it is not working with PRTG.

Created on Jan 27, 2017 7:44:13 PM



Votes:

0

Are you already using PowerShell sensors within PRTG? If not, you may need to work through step #1:
https://kb.paessler.com/en/topic/71356-guide-for-powershell-based-custom-sensors

Let me know if that's not the case or if it has worked :)

Created on Jan 30, 2017 6:23:59 AM by  Stephan Linke [Paessler Support]

Last change on Jan 30, 2017 6:24:07 AM by  Stephan Linke [Paessler Support]



Votes:

0

I don't see sensor comments as one of the placeholders that can be used.

We're wanting to just edit/customize the standard HTML notification mail to put the sensor comments higher (like right above the sensor status). This is mostly because we keep "how to fix this" notes in the comments, and want it more visible than having to scroll down past the graphs and so on.

If there's an easier way to do that than by making an all new custom template, that would be awesome too.

Created on Feb 2, 2018 3:40:22 PM



Votes:

0

You can sure use them. Assuming that it's your only placeholder, simply add {0} to the template and use the following parameters: -Placeholders @("%comments") This will replace {0} with the content of the comments field, preceeded by Comments:


Kind regards,
Stephan Linke, Tech Support Team

Created on Feb 3, 2018 11:30:17 AM by  Stephan Linke [Paessler Support]



Votes:

0

Stephan,

The code you provided didn't worked.

my Placeholders, from EXE:

`$Placeholders = @("sensorPARENTGROUP", "deviceURL", "sensorPARENTDEVICE", "sensorURL", "sensorNAME", "sensorSTATUSTEXT", "%datetime")`

my HTML snippet: `padding: 10px; border: 1px solid #ddd8d6;color:#00264d;"> {6}</td>`

All the placeholders worked, but the "%datetime".

May you help me?

Created on Aug 17, 2018 3:00:54 PM



Votes:

0

Could you post your entire template, please?


Kind regards,
Stephan Linke, Tech Support Team

Created on Aug 20, 2018 5:40:08 AM by  Stephan Linke [Paessler Support]



Votes:

0

Stephan,

Figured out how this part worked. I was trying to use the % placeholder type direct from the command line, and now I know it won't work, but does if I pass the parameters from PRTG notification, cool.

But now another problem: The notification as a whole ain't work if it's called from PRTG, but will if I do directly from command line, with the exactly same parameters. Any idea on what could lead to this?

Let me know if you need more info, but, the code as a whole is kind of the same up there (GitHub link), but filled with our credentials and with some $global:foobar removed.

Created on Aug 20, 2018 3:10:20 PM



Votes:

0

Do you see any errors under Logs | System Related | Notifications? Did you configure the Execution-Policy according to this article?


Kind regards,
Stephan Linke, Tech Support Team

Created on Aug 20, 2018 6:31:05 PM by  Stephan Linke [Paessler Support]



Votes:

0

After some good hours trying to figure it out, I did. Turned out the problem wasn't the script, nor PRTG, nor the script call by PRTG. The problem was the timeout setted by default in a custom exe notification, which is 5 seconds. Changed it to 60 seconds and it's working well now. Thanks for you assist, and, maybe, tell the devs to change the default timeout to something higher, maybe other people would get stuck in such thing too.

Regards, Jesus.

Created on Aug 20, 2018 7:08:57 PM



Votes:

0

I have now a simple problem. Since I can't use the %placeholder format within the script, I need to pass they as parameters in the PRTG call to the script. But, I need to place the placeholders as comma separated, but PRTG will put a ` before every comma, what makes the code fail to execute. Any ideas on how to make it work? my actual parameters line is: -SensorID %sensorid -Placeholders '%group','deviceURL','%device','sensorURL','%sensor','%message','%lastup'

Created on Aug 20, 2018 7:56:51 PM



Votes:

0

It should be -Placeholders @('%group','deviceURL','%device','sensorURL','%sensor','%message','%lastup')... but the parameter pass of special characters (@ and ( ) ) is currently broken :( I'm sorry that this is a somewhat tedious process currently :( The easiest would be to configure all placeholders directly in the script (in the parameters) and use them accordingly in the templates with their corresponding counters ({0}, {1}, etc.).


Kind regards,
Stephan Linke, Tech Support Team

Created on Aug 20, 2018 8:07:17 PM by  Stephan Linke [Paessler Support]

Last change on Aug 20, 2018 8:08:08 PM by  Stephan Linke [Paessler Support]



Votes:

1

Well, thats actually pretty sad, since the %placeholder style would work only if called as parameter from PRTG, not from the script, and it would inutilize most of the PRTG's placeholders. So, after some work, I made it work too.

In the script, comment the $Placeholders = @() line inside Params. Create a new line with $Placeholder = "", in it. It will create a String, instead of an Array, as the old variable. A little below, since the whole script is made to work with the placeholders as array, we need to convert the variable we just created to an array type. To do this we need the split method. Do it as follows:

[System.Array]$Placeholders = $($Placeholder -split ",,"); Important here is that the String one is Placeholder, in singular, meanwhile the array created above is in plural, as in the original code, so you don't need to change anything else.

Enough edit in the code, now the PRTG Parameters line in the custom exe notification should look something similar to this (but with your placeholders instead):

-SensorID %sensorid -Placeholder "%group,,deviceURL,,%device,,sensorURL,,%sensor,,%message,,%datetime"

The %sensorid will pass to the script the actual sensor, so it will work properly. Without this automation, the script has no sense at all.

I chose the double comma (,,) because I think it's something pretty hard to appear legimate in any part of the PRTG answer, or in any device name or anything else, but you could have chose anything, just remember to change it in the Split method in the code. After it your automatic notification with powershell should be working as expected.


Best regards,

Jesus.

Created on Aug 21, 2018 11:39:01 AM



Votes:

0

Thanks for the interim "patch" and sharing of the same! :)


Kind regards,
Stephan Linke, Tech Support Team

Created on Aug 21, 2018 11:50:37 AM by  Stephan Linke [Paessler Support]



Votes:

0

Why use such a complex system for custom email templates? Why not having something GUI based, which would be much more user friendly, like the map builder?

Almost everything custom within PRTG feels like a chore, rather than something you should be able to "just do"..

Created on Jun 7, 2019 9:10:07 AM



Votes:

0

We had it built-in, the code for it was very, very cumbersome, near impossible to maintain. Storing the HTML within the configuration, parsing it for malicious code, escaping control characters so they won't interfere with the configuration was a nightmare. That's why we decided to remove it.

We figured that we should give customers an opportunity to still send customized mails. I agree, it's comlplex to set up, but we don't have an alternative, unfortunately.

Created on Jun 11, 2019 6:16:46 AM by  Stephan Linke [Paessler Support]



Votes:

0

Hello, with "-SetupPasswords" you get a message that the function "PRTG-ShowMessage" was not found. I was able to fix this quickly. There was an error in line 133 and 389. I changed this to "Console-ShowMessage".

But a simple start of the Powershell causes the message: "None of the configured mailservers is responding". I am very sure that I have entered the correct credentials. Even a short test with an own Powershell Script with User/Password/SMTP Server/Port works without problems. Tested on the PRTG server with both configured SMTP servers. This ensures that the URL and ports go through.

Created on Jun 11, 2020 6:48:39 AM



Votes:

0

Hi, following your description, I run into multiple errors:

Whatever I put into "smtpHost", I get the error "None of the configured mailservers is responding, please check them for availability." but when I change line 145 from

"$tcpClient.Connect($global:servers.smtpHost,$global:servers.smtpPort)"

to

"$tcpClient.Connect("<myservername>",25)"

the error is gone. When I run the script from directly in PowerShell, I get a prompt for credentials and the following errors in the background:

"Exception calling "DownloadFile" with "2" argument(s): "Illegal characters in path."
At C:\Program Files (x86)\PRTG Network Monitor\Notifications\EXE\PRTG-SendCustomHTMLNotifications.ps1:303 char:9"

Exception calling "DownloadString" with "1" argument(s): "Illegal characters in path."
At C:\Program Files (x86)\PRTG Network Monitor\Notifications\EXE\PRTG-SendCustomHTMLNotifications.ps1:290 char:9
+         $sensorInfo = ($wc.DownloadString($url)) | ConvertFrom-Json;
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ArgumentException

Index operation failed; the array index evaluated to null.
At C:\Program Files (x86)\PRTG Network Monitor\Notifications\EXE\PRTG-SendCustomHTMLNotifications.ps1:314 char:9
+         $global:stateIcon = $stateIcons[$SensorInfo.sensordata.status ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArrayIndex

Index operation failed; the array index evaluated to null.
At C:\Program Files (x86)\PRTG Network Monitor\Notifications\EXE\PRTG-SendCustomHTMLNotifications.ps1:322 char:9
+         [hashtable]$placeholderTable = @{
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArrayIndex

New-Object : Exception calling ".ctor" with "2" argument(s): "Cannot process argument because the value of argument "userName" is not valid. Change the value of the "userName" argument and run the operation again."
At C:\Program Files (x86)\PRTG Network Monitor\Notifications\EXE\PRTG-SendCustomHTMLNotifications.ps1:190 char:23
+ ... edentials = New-Object -TypeName System.Management.Automation.PSCrede ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [New-Object], MethodInvocationException
    + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand

Please advise. If possible, we can also have a remote session for demonstration of the error.

Best regards, Caroline

Created on Nov 3, 2020 9:40:17 PM

Last change on Nov 5, 2020 6:41:56 AM by  Stephan Linke [Paessler Support]



Votes:

0

Sorry, this took somewhat longer to debug. The issue likely was that the $servers variable was not declared globally, at least it works like that for me. Please use the updated script accordingly and let me know if it worked :)

Created on Nov 5, 2020 8:00:53 AM by  Stephan Linke [Paessler Support]



Votes:

0

good afternoon mr prtg is giving me this error

Main;
[01/03/2021 16:25:45] [done]	All credentials found.
[01/03/2021 16:25:45] [info]	Checking mail server availability...
[01/03/2021 16:25:45] [info]	Using primary mail server
[01/03/2021 16:25:45] [info]	Setting up template paths...
Template or directory not found. Please make sure all folders and templates exist!

Created on Mar 1, 2021 4:27:21 PM

Last change on Mar 2, 2021 6:54:41 AM by  Felix Wiesneth [Paessler Support]



Votes:

0

Hi Juan,

Please see step 5 of the "How Do I Install the Script?" section.

Please note that you need to create the required "custom" folder in your \webroot\mailtemplates\ directory. With a PRTG installed in its default directories this would result in a manually created folder under:
C:\Program Files (x86)\PRTG Network Monitor\webroot\mailtemplates\custom

Best,
Sebastian

Created on Mar 2, 2021 1:52:08 PM by  Sebastian Kniege [Paessler Support]



Votes:

0

the folder to create it manually with says step 5, but I have doubts about the filling of this part

## mail configuration
[System.Collections.ArrayList]$global:recipientList = @();
[string] $priority              = "high"
## template configuration
[string] $templateBaseDir       = "C:\Program Files (x86)\PRTG Network Monitor\webroot\mailtemplates\custom"
[string] $templateDefaultLogo   = "C:\Program Files (x86)\PRTG Network Monitor\webroot\images\prtglogo.png"
[string] $Global:graphGUID      = [guid]::NewGuid()
[string] $iconFolder            = "C:\Program Files (x86)\PRTG Network Monitor\webroot\icons"
[string] $tempFolder            = "C:\temp";
[string] $global:stateIcon      = "";
## miscallenious
[hashtable]$directories = @{
    "templateBaseDir" = "C:\Program Files (x86)\PRTG Network Monitor\webroot\mailtemplates\custom";
    "tempFolder"      = "C:\temp";
    "iconFolder"      = "C:\Program Files (x86)\PRTG Network Monitor\webroot\icons";
    "templatePath"    = ""; }

Created on Mar 2, 2021 3:34:09 PM

Last change on Mar 2, 2021 3:34:09 PM



Votes:

0

Why's that, why do you have doubts?

Created on Mar 3, 2021 11:11:59 AM by  Sebastian Kniege [Paessler Support]



Votes:

0

Hi Paessler Support!

I'm trying the custom email script, but not matter what I do I always finish to receive the following message:

Retrieving users of PRTG group Test Notification Group Found 0 users in group Test Notification Group, sending to 1 contacts in total.

The group, obviously, contains some test users. The user account I'm using to access PRTG Server has the built in administrative rights. I've also already tested primary user assignment and other groups as well. What am I missing?

Thanks!

Created on Mar 3, 2021 3:06:02 PM



Votes:

0

what should i put in this part mr. prtg

[string] $global:stateIcon      = "";

"templatePath"    = ""; }

Created on Mar 4, 2021 4:09:42 PM



Votes:

0

Juan, regarding your question "what should i put in this part"? You can them empty, they'll be filled during execution.

Created on Mar 4, 2021 6:43:56 PM by  Sebastian Kniege [Paessler Support]

Last change on Mar 4, 2021 6:44:03 PM by  Sebastian Kniege [Paessler Support]



Votes:

0

Error sending "EXE": Error1. SNMP : The term 'SNMP' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:147 + ... s] BRCD_[...] (Sensor ID: 2437 | Trigger Source ID: 2437 | Trigger ID: 3)

Created on Mar 5, 2021 9:36:01 AM



Votes:

0

Unfortunately, we cannot really provide additional support for a script that old :( It's probably best to start over and configure it according to the guide here, as this has proven to work 100%. Make sure to run it in ISE for debugging so you can check what's going on.


Stephan Linke, Technical Support Team

Created on Mar 5, 2021 11:03:17 AM by  Stephan Linke [Paessler Support]

Last change on Mar 5, 2021 11:03:35 AM by  Stephan Linke [Paessler Support]



Votes:

0

[08/03/2021 14:45:06] [done]	All credentials found.
[08/03/2021 14:45:06] [info]	Checking mail server availability...
[08/03/2021 14:45:06] [info]	Using primary mail server
[08/03/2021 14:45:06] [info]	Setting up template paths...
[08/03/2021 14:45:06] [info]	Customized logo found.
[08/03/2021 14:45:06] [info]	Retrieving current live graph for sensor #2464
[08/03/2021 14:45:06] [done]	Graph downloaded and stored as C:\temp\0e258cd1-c659-49d6-90fa-135c58f38f3c.png
[08/03/2021 14:45:06] [info]	Preparing notification mail
[08/03/2021 14:45:06] [info]	Retrieving information for sensor #2464
[08/03/2021 14:45:06] [fail]	The notification could not be sent.
[08/03/2021 14:45:06] [info]	Removing live graph image. Exiting.

Created on Mar 8, 2021 2:47:01 PM

Last change on Mar 8, 2021 3:23:53 PM by  Felix Wiesneth [Paessler Support]



Votes:

0

So it seems like the mail itself cannot be sent via the script or the configured mail server. When running the following command in a PowerShell on the PRTG Server (replace accordingly):

Send-MailMessage -From "[email protected]" -To "[email protected]" -Subject "Testmail for PRTG" -Body "Hello World" -SmtpServer "your.mail.server.fqdn" -Port 465 -UseSsl -Credential (Get-Credential)

What error message do you get? Note that you may not be able to send as somebody else, depending on the account/server configuration of your mail server.

Created on Mar 10, 2021 8:00:31 AM by  Stephan Linke [Paessler Support]



Votes:

0

I know this is an old thread, but has there been any progress on getting the parameters from within PRTG to work properly for this script? I have the script running perfectly from the server itself, but like others, the parameters in PRTG Notifications won't work. I tried Jesus' modifications to the script, but I keep getting an error on

[System.Array]$Placeholders = $($Placeholder -split ",,");

Powershell does not like the semicolon at the end and a normal comma does not work either.

I know I could simply place the parameter in the script itself, but it always reports on the Root, not the specific sensor and forget about it attaching the Live Graph, that is not working either yet, but perhaps it is because of the sensor placeholder issue.

Anyone have any ideas for me?

Thanks

Created on Feb 25, 2022 6:42:30 PM

Last change on Feb 28, 2022 6:43:00 AM by  Felix Wiesneth [Paessler Support]



Votes:

0

Sorry for the delay - what does your parameter field actually look like?

Created on Mar 7, 2022 9:00:55 AM by  Stephan Linke [Paessler Support]



Votes:

0

How can I bypass entering a credential for the primary server. our internal SMTP relay does not use authentication.

Created on Nov 16, 2022 8:02:05 PM



Votes:

0

Hello,

the "SMTP Relay Authentication" option can be set to "Use no authentication".

Created on Nov 17, 2022 12:18:40 PM by  Arne Seifert [Paessler Support]



Votes:

0

I am having issues with actually running the script via the notification template. The script runs great using the interactive method from our PRTG server and we receive the email notification, but when testing the script using an simulated error, the logs report an "OK" for the execution but no email is received.

Command from testing interactively: .\CustomNotificataions.ps1 -SensorID 1026 -Recipients @("*****") -TemplateFolder "**" -Template "simple" -From "***" -Subject "[sensorPARENTDEVICE] [sensorNAME] Sensor is in sensorSTATUSTEXT state." -Priority "High" -PrimaryOnly

Parameter configuration in notification template: -SensorID %sensorid -Recipients @("***") -TemplateFolder "**" -Template "simple" -From "***" -Subject "[sensorPARENTDEVICE] [sensorNAME] Sensor is in sensorSTATUSTEXT state." -Priority "High" -PrimaryOnly

I suspect it is related to the fact the script is running noninteractively, but not sure how to remediate this.

Thanks for your help.

Created on Dec 6, 2022 2:00:49 PM



Votes:

0

Hello,

as there is no logging for programs run through a notification template, please add debug logging in the script to check where exactly it fails.

As log file destination, please do not use the local folder as it is usually protected, instead write to a folder like C:\Temp

Created on Dec 7, 2022 2:36:31 PM by  Arne Seifert [Paessler Support]




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.