How to Test Outgoing Emails in SharePoint using PowerShell
1 min read

How to Test Outgoing Emails in SharePoint using PowerShell

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
 
#Parameters
$EmailTo = "[email protected]"
$EmailSubject = "Test Email from SharePoint"
$EmailBody = "Test Email Body"
 
#Get the outgoing Email Server settings
$SPGlobalAdmin = New-Object Microsoft.SharePoint.Administration.SPGlobalAdmin
$SMTPServer = $SPGlobalAdmin.OutboundSmtpServer
$EmailFrom = $SPGlobalAdmin.MailFromAddress
 
#Using PowerShell 3.0 Send-Mail Message:
Send-MailMessage -To $EmailTo -From $EmailFrom -Subject $EmailSubject -Body $EmailBody -BodyAsHtml -SmtpServer $SmtpServer

Save as a testmail.ps1 and run it on an elevated powershell.

Enjoying these posts? Subscribe for more