What is SMTP4DEV?
Well, SMTP4Dev is a nifty tool for capturing and testing Emails from any application. It doesn't actually send any Emails to actual recipient, but it captures Emails triggered from applications such as SharePoint. Here is how we can utilize this tool for testing outgoing Emails from SharePoint.
This is extremely helpful in development environments and for testing purposes.
Step 1: Download SMTP4DEV tool from Codeplex
Download the SMTP4DEV tool from codeplex: https://smtp4dev.codeplex.com/ Standalone also available.! Just click and run the tool.
Step 2: Set Domain name in the tool
This tool runs from system tray area. The first thing you have to set is: configure the domain name as your current server name (by default it will be localhost).
Step 3: Configure the Outgoing Email settings in Central admin
Now in SharePoint 2013 (or in SharePoint 2010), set the outgoing email settings from SharePoint central administration site.
- Central Administration >> System Settings >> Configure outgoing e-mail settings >> add the same machine name in smtp4dev
Step 4: Write code / Set Alerts in SharePoint to trigger E-mails
Now, You can write your custom code/event receiver/workflow/Create alerts to send Emails from SharePoint. Here is my sample code to trigger Email with SPUtililty.SendMail using PowerShell:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue $siteUrl ="http://intranet.crescent.com" $Web = Get-SPWeb $siteURL $mail = [Microsoft.Sharepoint.Utilities.SpUtility]::SendEmail($web,0,0,"email@example.com","Subject of the Mail","mail body")
Here is the output:
As soon as an Email triggered from SharePoint, This tiny tool starts blinking and you should see messages appear in SMTP4Dev!
You can inspect the Email from the tool and open mails with any Email client such as Outlook.
You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.