Created
September 24, 2022 08:21
-
-
Save agehlot/dcdb4ff96263a6af34ac62f61025d029 to your computer and use it in GitHub Desktop.
This PowerShell script can be used to send an email or to test SMTP settings of any email service provider i.e. Azure SendGrid.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$From = "[email protected]" | |
$To = "[email protected]" | |
$SMTPServer = "smtp.sendgrid.net" | |
$SMTPPort = "587" | |
$Username = "apikey" | |
$Password = "[email protected]" | |
$subject = "Test Email" | |
$body = "Test email using SendGrid Email Delivery" | |
$smtp = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort) | |
$smtp.EnableSSL = $false | |
$smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password) | |
$smtp.Send($From, $To, $subject, $body) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment