Saturday, May 25, 2013

Set Outgoing E-Mail Settings for SharePoint Central Admin using PowerShell

Its a common task 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 
  • Click on "Configure outgoing e-mail settings"
  • Provide Outbound SMTP Server, From and To Addresses, and the character set.
  • Click "OK" to save your changes.

Set Outgoing E-Mail Settings for SharePoint 2013 using PowerShell:
Here is the PowerShell script in SharePoint 2013 to configure outgoing email

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Define Outgoing E-mail settings 
$outboundServer = 'g1exchangehub.crescent.org'
$FromAddress = 'Teamsites@crescent.org'
$ReplyAddress = 'SharePointSupport@crescent.org'
$Charset = 65001

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

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

This script sets outgoing email settings in SharePoint central Administration site.
Set Outgoing E-mail Settings with PowerShell 
PowerShell to Configure Outgoing Email Settings for SharePoint 2016: 
SharePoint 2016 introduces two more parameter to outgoing email settings: SMTP port and TLS Encryption. Here is the script to set outgoing email configurations for SharePoint 2016.
sharepoint 2016 configure outgoing email powershell

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
 
#Define Outgoing E-mail settings 
$outboundServer = "smtp.crescent.com"
$FromAddress = "Portal@Crescent.com"
$ReplyAddress = "Portal@Crescent.com"
$Charset = 65001
$TLSEncryption = $False
$SMTPport = 25
 
#Get Central Administrtion Web site 
$WebApp = Get-SPWebApplication -IncludeCentralAdministration | Where { $_.IsAdministrationWebApplication }
 
#Set outgoing Email settings
$WebApp.UpdateMailSettings($outboundServer, $FromAddress, $ReplyAddress, $Charset, $TLSEncryption, $SMTPport)

If you want set outgoing Email settings in MOSS 2007, Use:
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$CentralAdmin = New-Object Microsoft.SharePoint.Administration.SPGlobalAdmin
$CentralAdmin.UpdateMailSettings($outboundServer, $FromAddress, $ReplyAddress, $Charset)

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, IT@Company.com or IT departments and Sales@company.com 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 SharePointSupport@crescent.org -ReplyToEmailAddress SharePointSupport@crescent.org -SMTPServer emailserver.crescent.org

Its also possible to set outbound Email using STSADM command line. To setup outgoing Email for a particular web application:
stsadm -o email -outsmtpserver emailserver.crescent.org -fromaddress SharePointSupport@crescent.org -replytoaddress SharePointSupport@crescent.org -codepage 65001 -url http://server_name


To get outgoing email Server Settings using PowerShell:
At times, you may have to retrieve outgoing email settings using PowerShell, Say you want to send Email from the PowerShell script.
(Get-SPWebApplication -IncludeCentralAdministration | Where { $_.IsAdministrationWebApplication } ) | %{$_.outboundmailserviceinstance.server}

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



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


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...