Как то так, например, если на powershell:
function NoPing
{
$From = "server@email.ru"
$To = "admin@email.ru"
$SMTPServer = "smtp.email.ru"
$SMTPPort = "25"
$Username = "server@email.ru"
$Password = "password"
$subject = "server is down"
$body = Get-Date -Format "dd MMMM yyyy HH:mm:ss"
$message = New-Object System.Net.Mail.MailMessage $From, $To
$message.Subject = $subject
$message.IsBodyHTML = $true
$message.Body = $body
$smtp = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort)
# $smtp.EnableSSL = $true
$smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password)
$smtp.Send($message)
}
if (test-Connection -ComputerName 8.8.8.8 -Count 2 -Quiet)
{
exit
}
else
{
NoPing
}