Set SharePoint Web Application Email settings using PowerShell

Posted: September 25, 2014 in Wep Applications

When setting up new Web Applications left and right, it can be very frustrating to enter the email settings on the Web Applications. Under is a code-snippet and a Function to set email settings on your Web Applications using PowerShell.

Get-SPWebApplication | % {$_.UpdateMailSettings("smtp.domain.com", "SharePoint@domain.com", "SharePoint@domain.com", "65001")}

Here’s a simple function if you want individual settings on your Web Applications:

Function SetEmailSettings ($webapplication, $smtpServer, $FromAddress, $ToAddress)
{
$CharacterSet = "65001"
$webapp = get-spwebapplication $webapplication
$webapp.UpdateMailSettings($smtpServer, $FromAddress, $ToAddress, $CharacterSet)
}

Run Function like this:

SetEmailSettings -webapplication http://webappurl -smtpServer smtp.domain.com -FromAddress sharepoint@domain.com -ToAddress sharepoint@domain.com

Or just

SetEmailSettings http://webappurl smtp.domain.com sharepoint@domain.com sharepoint@domain.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s