SharePoint eine Test-Mail versenden lassen

Auf die spannende Frage “Warum versendet SharePoint keine Mails?” gibt es in der Regel nur wenige Antworten.
Wenn die Einstellungen der ausgehenden Mails (“Configure outgoing e-mail settings”) in SharePoint gut aussehen hilft meistens nur testen und das ULS-Log beobachten.

Das folgende PowerShell-Skript kann verwendet werden um schnell Test-Mails aus dem SharePoint versenden zu lassen (Dabei kann man dann das ULS-Log – am besten mittels ULS Viewer – beobachten)

Sends a Test-Mail using SharePoint-Standard Tools
returns "TRUE", if the mail was successfully "taken in" with SharePoint (most probably also given to smtp...)
and "FALSE" if there was any failure to do so.
Check your ULS-Logs for further investigation if the result is FALSE, or your smtp-server-logs if the result is TRUE
"TO" field of the mail.
The Url to the SPWeb to access via the SharePoint e-Mail utilities
"FROM" field of the mail. defaults to ""
"SUBJECT" field of the mail. Defaults to "Test" and a Date.
"BODY" of the mail. Defaults to some nice text.
Send-SPTestMail -Web -From
Sends a simple mail using all the nice deafults..
param (
[string]$From = "",
[string]$Subject = $null,
[string]$Body = $null
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction Stop
$headers = new-object System.collections.Specialized.StringDictionary
if(!$Subject) {
$Subject = "Test @ $(Get-Date)";
$Body = "Auto-Generated body of test-mail <ul><li>Generated at $(Get-Date)</li><li>Headers:<ul>";
$headers | % { $Body += "<li>$($_.Name): $($_.Value)</li>"; }
$Body += "</ul></li><li>Sent via SharePoint-Web at $($Web)</li></ul>";
$spweb = $null;
try {
$spweb = Get-SPWeb $Web -ErrorAction Stop
} finally {
if($spweb -ne $null) {
view raw Send-SPTestMail.ps1 hosted with ❤ by GitHub