SharePoint 2013 : Fonction PowerShell pour configurer l’envoi de message via SMTP (Outgoing Email)
Dans la liste des fonctions utilisables dans vos scripts de configuration de ferme SharePoint, voici une nouvelle fonction pour configurer SharePoint afin d’utiliser le serveur de messagerie SMTP :
[string]$SMTPServer = "MySMTP-Server.com"
[string]$emailAddress = "EmailAddress@myCompany.com"
[string]$replyToEmail = "EmailAddress@myCompany.com" Function ConfigureOutgoingEmail
{
Try
{
Write-Host -ForegroundColor White " - Configuring Outgoing Email..."
$loadasm = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$spGlobalAdmin = New-Object Microsoft.SharePoint.Administration.SPGlobalAdmin
$spGlobalAdmin.UpdateMailSettings($SMTPServer, $emailAddress, $replyToEmail, 65001)
}
catch [system.exception]
{
Write-Host -ForegroundColor Yellow " ->> ConfigureOutgoingEmail caught a system exception"
Write-Host -ForegroundColor Red "Exception Message:", $_.Exception.ToString()
}
finally
{
Write-Host “ SMTP Configuration done”
}
}
ConfigureOutgoingEmail
Ce script est indépendant de l’édition de SharePoint (Foundation ou Server), car la configuration en question est commune.
D’autres fonctions viendront alimenter ce script global qui sera publié en fin. L’idée est de pouvoir prendre ces fonctions comme des briques de base pour votre propre solution de déploiement.
Romelard Fabrice [MVP] - MBA Risk Management
Ce post vous a plu ? Ajoutez le dans vos favoris pour ne pas perdre de temps à le retrouver le jour où vous en aurez besoin :