Been looking for something like this in a while to test newly setup or existing SMTP setups for simple server notification or business applications e.g. SharePoint, as it saves you having to install telnet or putty in order to send a quick test email to make sure its not getting blocked somewhere i.e. spam: ## Update ## Just found out there’s an actual powershell Cmdlet for this: Send-MailMessage!
$msg = new-object Net.Mail.MailMessage #Creating SMTP server object $smtp = new-object Net.Mail.SmtpClient($smtpServer) #Email structure $msg.From = "fromID@xxxx.com" $msg.To.Add("toID@xxxx.com") $msg.subject = "My Subject" $msg.body = "This is the email Body." #Sending email $smtp.Send($msg)
Thanks to SharePoint and Others for the basics!