Redirecting Outgoing Emails in Sharepoint 2013

There’s a few problems with Sharepoint’s mail handling:

  • task generated emails cannot be disabled by design
  • no way to selectively route emails based on conditions or content

In my case, the non production server testing was sending tasks to live member unintentionally. I didn’t want to use smpt4dev because it was largely intended for developers and administrators to view the emails from the sharepoint server, I wanted an easy way for selective department members who were stakeholders of the project to preview the emails and confirm the workflow behaviour before it went onto production.

The ideal solution is to route it through a mail server which can do extra processing before it reaches the destination. I am still writing that piece in nodejs and have not found the time to complete it. A quick solution I took was to set Sharepoint server’s outgoing mail to a Linux box which had postfix installed. From there I added header redirect conditions to redirect all emails into one mailbox.

vim /etc/postfix/header_checks.regexp

and the contents of the file would be something like:

/    REDIRECT        sharepointdev@company.local
/    REDIRECT        sharepointstaging@company.local

where the ips are the ips of the sharepoint servers and the email addresses are the mailbox of the intended account to host all the email workflows and tasks.