{"id":5222,"date":"2024-12-14T08:55:13","date_gmt":"2024-12-14T16:55:13","guid":{"rendered":"https:\/\/SUMMALAI.COM\/?p=5222"},"modified":"2024-12-14T08:58:21","modified_gmt":"2024-12-14T16:58:21","slug":"how-to-send-email-notifications-when-ping-fails","status":"publish","type":"post","link":"https:\/\/SUMMALAI.COM\/?p=5222","title":{"rendered":"How to Send Email Notifications When PING Fails"},"content":{"rendered":"\n<p>PingInfoView&nbsp;is available to download from here:<\/p>\n\n\n\n<p><a href=\"https:\/\/www.nirsoft.net\/utils\/multiple_ping_tool.html\">PingInfoView &#8211; Ping to multiple host names\/IP addresses<\/a><\/p>\n\n\n\n<p>One of the common feature request for the PingInfoView tool is to send an email message when a ping fails. although the PingInfoView tool doesn&#8217;t have an option to send an email message, you can still do it by using the combination of PowerShell script and the &#8216;Execute the following command on failed ping&#8217; option.<\/p>\n\n\n\n<p>First, you have to create a PowerShell script that accepts as parameters the information about the failed ping and then sends it as email message. If you are not a programmer, don&#8217;t worry, here&#8217;s a ready-to-use script that will do this job:<br><\/p>\n\n\n\n<p>$Username = &#8220;YourMailUser&#8221;;<br>$Password = &#8220;YourMailPassword&#8221;;<br>$SendTo = &#8220;sendto@yourdomain.com&#8221;;<br>$MailServer = &#8220;mail.yourdomain.com&#8221;;<br>$HostName = $args[0];<br>$IPAddress = $args[1];<br>$PingStatus = $args[2];<br>$FailedOn = $args[3];<\/p>\n\n\n\n<p>$message = new-object Net.Mail.MailMessage;<br>$message.From = $Username;<br>$message.To.Add($SendTo);<br>$message.Subject = &#8220;Failed Ping On $HostName&#8221; ;<br>$message.Body = &#8220;Information about the failed ping: `r`nHost Name: $HostName`r`nIP Address: $IPAddress`r`nPing Status: $PingStatus`r`nPing Time: $FailedOn&#8221;;<\/p>\n\n\n\n<p>$smtp = new-object Net.Mail.SmtpClient($MailServer, &#8220;587&#8221;);<br>$smtp.EnableSSL = $true;<br>$smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password);<br>$smtp.send($message);<\/p>\n\n\n\n<p>Before you use this script, you still have to update the first 4 lines with your email information:<br>First Line &#8211; The user name on your SMTP server for sending the message.<br>Second Line &#8211; The password on your SMTP server for sending the message.<br>Third Line &#8211; The email that will receive the failed ping message.<br>Fourh Line &#8211; The address of your SMTP server for sending the message<\/p>\n\n\n\n<p>After updating the email information, save the script to .ps1 file, for example: send_message_failed_ping.ps1<br>You can use Notepad or any other text editor.<\/p>\n\n\n\n<p>Now you have to update PingInfoView to run the PowerShell script when a ping fails. In PingInfoView, press F9 (&#8216;Advanced Options&#8217; window), select the &#8216;Execute the following command on failed ping&#8217; option and then type the command to run the PowerShell script:&nbsp;<strong>Powershell.exe -executionpolicy remotesigned -File F:\\Scripts\\send_message_failed_ping.ps1 &#8220;%HostName%&#8221; &#8220;%IPAddress%&#8221; &#8220;%LastPingStatus%&#8221; &#8220;%LastFailedOn%&#8221;<\/strong><\/p>\n\n\n\n<p>In the above command example, the script is saved on F:\\Scripts\\send_message_failed_ping.ps1, and obviously you have to put the correct script filename on your system.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.nirsoft.net\/articles\/failed-ping-powershell-send-email-command.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>Assuming that you did everyting correctly &#8211; when a ping fails on PingInfoView, you&#8217;ll receive an email message that looks like this:<br><img decoding=\"async\" src=\"https:\/\/www.nirsoft.net\/articles\/failed-ping-email-message.png\"><\/p>\n\n\n\n<p>Ref: <a href=\"https:\/\/www.nirsoft.net\/articles\/send-email-message-on-failed-ping.html#google_vignette\">How to send email message when a ping fails using the PingInfoView tool<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>PingInfoView&nbsp;is available to download from here: PingInfoView &#8211; Ping to multiple host names\/IP addresses One of the common feature request for the PingInfoView tool is to send an email message when a ping fails. although the PingInfoView tool doesn&#8217;t have an option to send an email message, you can still do it by using the <a class=\"read-more\" href=\"https:\/\/SUMMALAI.COM\/?p=5222\">Read More<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[9,569,14],"tags":[1833,1834],"class_list":["post-5222","post","type-post","status-publish","format-standard","hentry","category-networks","category-others","category-windows-7-8-10","tag-how-to-send-email-notifications-when-ping-fails","tag-pinginfoview"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts\/5222","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5222"}],"version-history":[{"count":2,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts\/5222\/revisions"}],"predecessor-version":[{"id":5225,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts\/5222\/revisions\/5225"}],"wp:attachment":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5222"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5222"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5222"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}