This tutorial will help you to send an email from the Windows command line via remote SMTP server. You need SMTP server details for sending email from Windows PowerShell command.
Send Email from Windows PowerShell
Once you have SMTP details, open Windows PowerShell and execute the following commands one by one. You need to change the
$EmailFrom = “
[email protected]” $EmailTo = “ [email protected]” $Subject = “ Email Subject Here” $Body = “ This is mail body” $SMTPServer = “ smtp.gmail.com” $SMTPClient = New-Object Net.Mail.SmtpClient($SMTPServer, 587) $SMTPClient.EnableSsl = $true $SMTPClient.Credentials = New-Object System.Net.NetworkCredential(“ SMTP Username”, “ SMTP Password”); $SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)
This will send email to the recipient address via defined remote SMTP server. You can also write this in a PowerShell script and execute.