Saturday, May 25, 2013

Set Outgoing E-Mail Settings with PowerShell

Its a common tasks that every SharePoint administrator will have to perform is enabling SharePoint to send E-mails. Outgoing email settings can be configured within the Central Administration site by navigating to:

  • Central Administration >> System Settings >> Configure outgoing e-mail settings
Set Outgoing E-mail Settings in SharePoint 2010

To Set Outgoing E-Mail Settings with PowerShell:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Define Outgoing E-mail settings 
$outboundServer = ''
$FromAddress = ''
$ReplyAddress = ''
$Charset = 65001

#Get Central Administrtion Web site 
$WebApp = Get-SPWebApplication -IncludeCentralAdministration | Where { $_.IsAdministrationWebApplication }

#Apply the Settings
$WebApp.UpdateMailSettings($outboundServer, $FromAddress, $ReplyAddress, $Charset)

If you want it for MOSS 2007, Use:
$CentralAdmin = New-Object Microsoft.SharePoint.Administration.SPGlobalAdmin
$CentralAdmin.UpdateMailSettings($outboundServer, $FromAddress, $ReplyAddress, $Charset)
Set Outgoing E-mail Settings with PowerShell  
Setup outgoing Email for a particular web application:
Its also possible to set outbound Email settings per web application. But in Central Administration, outgoing email settings are set globally to the Farm but not per web application. Say for e.g, We need different From/To addresses for different departments in the organization. Say, or IT departments and for sales department.

This is where PowerShell comes to handy!We can set outbound Email settings per web application using PowerShell:
Get-SPWebApplication -Identity <web-app-url>
Set-SPWebApplication -OutgoingEmailAddress -ReplyToEmailAddress -SMTPServer
Its also possible to set outbound Email using STSADM command line. To setup outgoing Email for a particular web application:
stsadm -o email -outsmtpserver -fromaddress -replytoaddress -codepage 65001 -url http://server_name

To get the outgoing email Server Settings:
(Get-SPWebApplication -IncludeCentralAdministration | Where { $_.IsAdministrationWebApplication } ) | %{$_.outboundmailserviceinstance.server}

Technet Reference: Configure outgoing e-mail for SharePoint Server 2010

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.

Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...