I was playing around with SharePoint Online Hub Sites today and noticed something interesting... You might be asking yourself what are Hub Sites?! Read all about them here: https://techcommunity.microsoft.com/t5/SharePoint-Blog/Organize-your-intranet-with-SharePoint-hub-sites/ba-p/174081 Note:...
Recently setup outbound SMTP in an Azure SharePoint farm. There is great documentation (https://azure.microsoft.com/en-us/documentation/articles/sendgrid-dotnet-how-to-send-email/) out there already, but figured I’d share my experiences with it.
Included in Azure is a cloud-based email service called SendGrid. You get 25,000 email credits free a month. Here’s the rest of the pricing: https://sendgrid.com/windowsazure.html
Once this service is created in your environment (Click the first link to get the walkthrough) you will be assigned a username/password for SMTP relay. Make note of this since you’ll be using it later on.
After the SendGrid service is spun up you still need a way for SharePoint to use this. Pointing the outbound email configuration at smtp.sendgrid.com will not work because SendGrid requires a username/password. Good thing SendGrid has some good documentation too: https://sendgrid.com/docs/Integrate/Mail_Servers/iis75.html
After configuring the SMTP Server feature on the SharePoint server (You could use a separate server for relay, but this was dev so I was playing) I tested first with Telnet (Using the example in the SendGrid documentation) and then with PowerShell to verify everything was working in SharePoint.
The documentation is good so follow that, but I did run into 2 items that weren’t discussed:
- Add your domain as an alias domain in SMTP
- The IP Address of 127.0.0.1 does not work
- In SMTP > Right Click the SMTP Virtual Server # 1> Properties > Access > Relay Restrictions
- Click the Relay button and note that 127.0.0.1 is added (Per SendGrid instructions). This needs to be switched to the IP Address of the Azure server
- The Only the List below Radio button should be selected. You could use the “Allow all computers which successfully authenticate..” option, but this puts you at risk for being an open relay!
- Source: http://blogs.technet.com/b/jhoward/archive/2005/10/11/412328.aspx
Here’s the PowerShell example:
#replace email with actual email address
$email = "email@example.com"
$subject = "Test subject"
$body = "Test body"
$site = New-Object Microsoft.SharePoint.SPSite "http://webappaurl/"
$web = $site.OpenWeb()