Code to test SMTP or mail server or Power shell to test SMTP or mail server
Code to test SMTP or mail server or Power shell to test SMTP or mail server
Happy Azuring!
Code to test SMTP or mail server or Power shell to test SMTP or mail server
This file contains 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
#Just change the $MailTo and you can copy/paste this into a Power shell window. | |
# Sender and Recipient Info | |
$MailFrom = "test@google.com.sg" | |
$MailTo = "pandit.umesh@outlook.com" | |
# Sender Credentials | |
$Username = "test@google.com.sg" | |
$Password = "%%%%%%%%7" | |
# Server Info | |
$SmtpServer = "smtp.google.com" | |
$SmtpPort = "789" | |
# Message stuff | |
$MessageSubject = "test smtp.google.com ssl" | |
$Message = New-Object System.Net.Mail.MailMessage $MailFrom,$MailTo | |
$Message.IsBodyHTML = $true | |
$Message.Subject = $MessageSubject | |
$Message.Body = @' | |
<!DOCTYPE html> | |
<html> | |
<head> | |
</head> | |
<body> | |
This is a test message. | |
</body> | |
</html> | |
'@ | |
# Construct the SMTP client object, credentials, and send | |
$Smtp = New-Object Net.Mail.SmtpClient($SmtpServer,$SmtpPort) | |
$Smtp.EnableSsl = $true | |
$Smtp.Credentials = New-Object System.Net.NetworkCredential($Username,$Password) | |
$Smtp.Send($Message) |
Happy Azuring!
Thanks & Regards,
Mail ID: pandit.umesh@hotmail.com
Skype ID: pandit.umesh