This project has moved and is read-only. For the latest updates, please go here.

Incoming E-Mail service

May 9, 2011 at 1:00 PM
Edited May 9, 2011 at 4:03 PM

The current script only sets up the outbound email service, not the inbound. The following code could be adapted to include a basic inbound email service in the installation. It does not include configuration of the directory management service, although adding it should only require setting more properties on $IncomingMailService

Import-Module ServerManager

#Install the SMTP server
$smtpfeature=Get-WindowsFeature SMTP-Server
if ($smtpfeature.Installed) {
	Write-Host "SMTP Server already installed"
	Write-Host "Installing SMTP Server..."
	Add-WindowsFeature SMTP-Server

#Boost the maximum message size to 10Mb - this should go in the XML config file
cscript C:\Inetpub\AdminScripts\adsutil.vbs SET SMTPSVC/MaxMessageSize 10485760

#Enable logging
cscript C:\Inetpub\AdminScripts\adsutil.vbs SET SMTPSVC/LogType 1

#Set startup type
Set-Service SMTPSVC -StartupType Automatic

#Ensure it is running
Start-Service SMTPSVC

#Obtain a reference to the SharePoint incoming email service application
$loadasm = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$Farm = [Microsoft.SharePoint.Administration.SPFarm]::Local
$IncomingMailService = [Microsoft.SharePoint.Administration.SPServiceCollection].GetMethod("GetValue",[String]).MakeGenericMethod([Microsoft.SharePoint.Administration.SPIncomingEmailService]).Invoke($Farm.Services,"")

#Enable sharepoint incoming email

#Configure permissions on drop folder
$Acl = (Get-Item "C:\Inetpub\mailroot\drop").GetAccessControl("Access")
$Ar = New-Object"WSS_ADMIN_WPG","FullControl","ContainerInherit, ObjectInherit","None","Allow")
$Ar2 = New-Object"WSS_WPG","Read","ContainerInherit, ObjectInherit","None","Allow")
Set-Acl -aclobject $Acl "C:\Inetpub\mailroot\drop"