Working with PowerShell the next step is to enable additional features in my scripts. This script will send email directly from within PowerShell.
Hope this helps someone.
[sourcecode language=”css”]
#################################################
# Name: SMTPAnonTest.ps1 #
# Author: Carlos Vargas #
# Email: cvargas at cavarpe dot com #
# Version: 1.0 #
# Purpose: Test Anonymous Relay #
#################################################
#################################################
# Requirements #
# 1. Set Powershell Script Execution #
# – Set-ExecutionPolicy RemoteSigned #
#################################################
###############
# Heading #
###############
Write-Host "SMTP Anonymous Test will help you test your anonymous SMTP Relay Setting"
Write-Host "Author: Carlos Vargas"
Write-Host ""
###############
# Variables #
###############
$smtpServer = Read-Host -Prompt "Type SMTP Server"
$mailfrom = Read-Host -Prompt "From"
$mailto = Read-Host -Prompt "To"
$mailsubject = Read-Host -Prompt "Subject"
$mailbody = Read-Host -Prompt "Body"
################
# Mail Process #
################
$msg = new-object Net.Mail.MailMessage
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$msg.From = $mailfrom
$msg.To.Add($mailto)
$msg.Subject = ($mailsubject)
$msg.Body = ($mailbody)
$smtp.Send($msg)
[/sourcecode]