The Ops Community ⚙️

Joseph Deblasio
Joseph Deblasio

Posted on

PowerShell SMTP code

PowerShell SMTP code

Joseph deblasio

use mailtrap.io for SMTP relay port 25

$message = New-Object Net.Mail.MailMessage;
$message.From = "me@datacenter.com";
$message.To.Add($email);
$message.subject = "Sending alert for process 13";
$message.Body = "This is a critical Alert - Action Required";
$smtp = New-Object Net.Mail.SmtpClient("smtp.google.com", 587);
$smtp = EnableSSL = $true;
$smtp.credentials = New-Object System.Net.NetworkCredential($Username, $Password);
$smtp.Send($message);

Top comments (0)