A MailServer For Win2k8-Based SharePoint Dev
If you are among the millions who adore the most recent release of Microsoft Windows’ server line of operating systems , Windows Server 2008, you have completely shifted [at least] your SharePoint dev environment to this great server platform. First of all it is the most stable OS ever. Why would u want to develop anywhere else? (Real man only develops on Server OS not something like Vista 😉 ). Secondly every single driver and program I use works perfectly ; Needless to say that I ONLY work on x64 machines all the way through and all Vista x64 drivers works just fine for me. Okay , admittedly I have one issue in my development environments though. It is the MailServer!
Let’s say you are developing Workflows , event handlers , alerts or generally any SharePoint custom dev that requires sending (and receiving) emails. Obviously , you will want to be able to test the email generating functionality.right? Truth to be told , there are couple of issues here:
- Not every developer is spoiled by having Exchange and AD on their dev machine or [if they are too much spoiled] on their dev farm!, but again many of us develop in virtualized environments and the question is why would we want to run a resource-intensive application such as Exchange Server on our Windows 2008 dev system where every free bits matter?
- Okay what about POP3 ?! Well, fortunately or unfortunately POP3 mail protocol is no longer shipped with Windows 2008 Server , so even at organizational level if you happen to be using POP3 , once you migrate over to Win 2008 you will have to use other applications such as Exchange or Small Business Server (SBS) ,so Pop3 is out of question too.
- Windows 2008 Server is shipped with SMTP Service , but it is still running in IIS6 mode. Truthfully, once you go for IIS7.0 , you can’t go back to IIS 6.0 again . It is like driving a mountain bike after years & years of owning a yellow Lamborghini Gallardo! Just as a side note , I WANT that freaking chick-killer car (I have no idea if there is such an expression as chick-killer in English , but anywho!).I just need someone to teach me how to save my money 🙂
- You certainly don’t want to send mail traffic via company SMTP server or Exchange as well- no dice!
The best news is that there are many free standalone Mail Servers out there that can get you setup in a heart beat! In this blog post , I am demonstrating how you may use SmarterMail – a fully RFC compliant mail server package with a nice ASP.NET-based administrative console. I have been using this mail server since I shifted the gears to Windows 2008 and it works pretty slick for me.
1) Install SmarterMail Version 5.x which is available here.Their free version comes with many features , truthfully way more than what you may need.
2) Installation is pretty straightforward and it installs the administrative Web console at port 9998 by default, so go ahead and Log into SmarterMail with username admin and password admin.
3) You can override the default installation setting using SmarterMail Web Server Config utility which is shipped as part of the installation.
4) Right after you log in , you must change the default admin password. Type the new password and Click Next.
5) In this wizard, you need to specify the IP of Primary DNS and Secondary DNS. Let’s just go ahead and only point the Primary DNS to 127.0.0.1. Leave all the other wizards with default values and Click Finish.
6) Once you logged into the administrative Web console , in the Manage tab, choose All Domains node from the left tree view and click on New icon on the right pane.
7) In this step we will define our new domain. I named mine dhdevsrv.com , but feel free to name yours whatever you wish. Also point the IP address to 127.0.0.1. Then we need to define an administrator for this domain who can be the same as the system administrator credentials we just entered to login to the administrative Web console! Click Save once you’re done.
.8) In the page which shows your newly defined domain , click on the Settings menu and choose Users.
9) Proceed with defining a new user – say user1, pass@word1. You also need to add the same user to your local users. Remember , we don’t have a domain controller , so there is no way to assign the emails we defined in SmarterMail to the user we defined locally at OS level. That assignment should be done at each site collection for which we require email functionality. I will cover this in the next step. PBP! ( Meaning Please Be Patient!)
10) Now, It is time to make SharePoint aware of the existence of our new MailServer. Go to the Central Administration site > Operations tab and click on the Outgoing Email Settings. Fill out the required fields based on your domain and user definitions in the previous steps. Click Ok.
11) Now , we need to add our famous user (user1) to a site collection and edit his email so SharePoint is aware of the email address. As I alluded to earlier , you need to do this for each site collection for which email functionality is required. SharePoint maintains a hidden list called User Information List which will be consulted if required to extract user’s basic information such as SIP address, Job Title , Email and etc. This list is maintained at each site collection level hence this association between the email address and the local user must be repeated for each site collection. Yes, that’s the only gotache , but minor for development purposes.
12) Next step would be updating your host file , located at C:\Windows\System32\drivers\etc , to reflect the new domain name we just entered in the previous step. Point it to 127.0.0.1.
13) Obviously , you should define the new account in outlook , so you can receive the emails:
It is time to test the installation, let’s start by Outlook …….. And it is nicely working:
Yeap! SharePoint picked up the email address when user1 subscribed to a document library alert :
It’s about time to write a simple PowerShell script to test the new MailServer using the actual object model called by my favorite class, SPUtility and its lovely static method SPUtility.SendEmail:
- $null = [Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
- $spSite = new-object Microsoft.SharePoint.SPSite("http://dhdevsrv")
- $spWeb = $spSite.OpenWeb()
- $email = "user1@dhdevsrv.com"
- $emailSub= "MailServer Demo!"
- $emailBod= "<b>Sent from a PowerShell script!</b>"
- $outcome = [Microsoft.SharePoint.Utilities.SPUtility]::SendEmail($spWeb,$false,$false,$email,$emailSub,$emailBod,$false)
- if ($outcome)
- {Write-Host "Email Sent"}
- else
- {Write-Host "Oops! Something's off"}
Check user1’s mailbox. The following email pops into his mailbox upon the execution of the PowerShell script:
You just setup a MailServer on your dev environment in 13 easy steps. Absolutely no need to install Windows 2008 SMTP service (one less service to worry about on your dev server) and no need to be worried about why POP3 has been deprecated. You have a standalone MailServer on you development environment that works perfectly with all of your SharePoint development bits. Enjoy Developers!
P.S. I really liked what SmarterMail people wrote here in “Why a Free Edition?” paragraph. Well Said! it is all about giving back.
Would this be compatible with the incoming emails you can have with lists. I was under the assumption this looked at the SMTP service in inetpub folder?
No , this doesn’t work with Email-enabled doc libs EXACTLY for the same reason you mentioned. This blog post is more geared towards standalone Win2k8-based SharePoint development machines. As you can see above , I don’t even talk about Central Administration>Operations>Incoming E-Mail Settings where you setup email drop folder! If that functionality is required , you can stop SmarterMail SMTP In and Out service and leverage Windows 2k8 SMTP service managed by 1970s-style IIS 6.0 interface LOL
HA HA, yeah the incoming email is certainly a black box of sorts! Unfortunately most clients love it when they see it working. We’ve had issues with the formats of the emails and attachments meaning they just disappear. So from a records management stand point it’s not 100%!
Well , setting up SharePoint to receive emails sucks in every aspect you can think about. The biggest pet peeves I have with incoming emails is that let’s say you’re accepting emails from external domains and you have set your Sharepoint site to accept emails from authenticated users ONLY. Guess what!!, you cannot prevent others from impersonating your email identity- meaning that I can send an email and pretend that I am you (which is not rocket science , right?) so my email will show up in the list as if it was from you.Sure you can write custom code or ask for signature kind of verification , but that’s how ootb incoming emails works. Painful!
Speaking of incoming emails, I have always had issues with successfully implementing email enabled Groups. Every time I try, I get an AD DL created in the Organizational Unit. The issue is , it is for xxx@devhorizon.com rather than xxx@yyy.devhorizon.com; therefore messages sent to that DL do not get forwarded to the members of the SharePoint Group. Any thoughts?
I like your taste in cars my friend – the Lambo is my dream car as well, but I doubt saving up will get us anywhere close to affording something like that.. maybe winning the lotto? 🙂
Actually , in north American style of living , 90% of your life is based on the credit and debt … so I really meant to save that 10% down , brother LOL I am not that much off, ain’t I? 😉
In that case, you should have one by next year 🙂 I, on the other hand, will probably never own a Lamborghini since tax on cars in Jordan is 80%.. which means I’ll need to save up $400k… sad, but true 🙁
Yeah, I’ve never gone that far with email for SharePoint Groups. I’m sure some exchange gurus could come up with a resolution for that one.
BTW, nice work with the PowerShell script for SMTP. A great way to check everythings up and running email wise within a new Farm 😉
Thanks Jeremy , lots of PoSh stuff coming soon! I just need my days to be longer than 24 hrs so I can put more stuff on my blog…. You are a blogger so you feel me 😉
Muhanad,
Same thing in IRAN! for people like us it is impossible to EVER drive such a car. Not because of tax but simply because life is so expensive that buying such a car requires you to own pretty much a SharePointCodeFactory! and more importantly a HyperLink to the government 🙂
In Canada (North America) though , everything is reachable! The trick is once you get there, you will become corporations’ slave for the rest of your life! I guess the trade off is to choose between “Dying with a lot of regrets” OR “Being an slave for the rest of your life” (meaning working your ass off to pay interest and making someone else rich).
The third option is to train your eyes in a way that they can ignore all the superficial colors of today’s life. Regrettably my eyes don’t work that way LOL , seriously man! I have purchased 4 laptops in 2008 , did I really need them? Maybe 2 of them , the other two was just because I wanted to have them or you bought it you rob it on my face and it made me feel that I want it too hahahaha. It is a sad sickness 🙂 Being in technology makes you a REAL consumer and it affects every aspect of your life.
Fantastic, been working on this for days with HMailServer but no luck…Will get this going tonight…
as for the Lambo, yes as long as it is one f those F1 boats…
I would much rather an Aston Martin…
regards
Sean
Love this article Reza. Thank you for bringing it to everyone’s attention. Definitely one of many posts that I have bookmarked!
The best information i have found exactly here. Keep going Thank you
Wierd. This October 2008 post *just* showed up in my twitter feed (in July 2009). I swear I saw this post somewhere else and I swear I wrote comments about using hMailServer (which is always free, there is no lite edition). So yeah, check out hMailServer. I use it on all my SharePoint server setups.
@Bil Simser You emailed that directly to me and a bunch of other MVPs.
I use MailEnable which gives similar functionality and is free.
Thanks for this post! I can now use an SMTP server and test some SharePoint code!
Checking the mail can also be done by using the SmarterMail itself. Just logon with user1 (in your example) (so you don’t need to install Outlook :)).
@Robje
That’s true. However, I use outlook because you can get all emails (from all account)without having to login to the web UI multiple times.
Thanks, Works Great!