SharePointCommunity
Die deutschsprachige Community für SharePoint, Microsoft 365, Teams, Yammer und mit Azure
SharePoint 2013 virtual DEV environment - Mail settings

Blogs

Oliver Wirkus

Syndication

Certifications

Web 2.0

http://smits-net.de/img/linkedin_button.gif

XING

http://i80.photobucket.com/albums/j191/mikesamerica/twitter_button_zpsee74f711.png

 

 Add to Technorati Favorites

 

 Delicious Bookmark this on Delicious

 

  Locations of visitors to this page

 

Did you ever setup a virtual SharePoint 2013 development environment? I just did - and I did it the same way I did several months ago when I setup a virtual development environment for SharePoint 2010. And I finally got stuck on the same problem - what about sending and receiving mails?

My virtual development environment was again based on VMWare Workstation 9 and I created a single server SharePoint 2013 environment  with Windows Server 2012, SQLServer 2012 and SharePoint 2013. This should be a virtual development environment that our consultants can use on their notebooks and that is why I needed to have an eye on the final size of the VM. I did not install Exchange and Outlook and wanted to use local accounts.

Although it took me several hours to setup this VM (a fast notebook with a SSD and lots of RAM is speeding up the installations considerably) I finally managed to get SharePoint 2013 up and running. I configured the User Profile Service Application, configured the MySites and the Search Service Application. A quick look on SharePoint 2013 showed no problems.

Now I wanted to configure mail. Outbound mail was sufficient for this DEV VM. A few days ago I stumbled on a very helpful tool created by Robert Wood. This tool is called smtp4dev and can be downloaded at codeplex: http://smtp4dev.codeplex.com/. This tool just simulates a SMTP server and is incepting all mail traffic. It also is able to show the mail itself (Source, Header and Body). I t did not require the server’s SMTP service nor the server to be configured as SMTP server. Indeed both should be switched off or disabled!

image

image

 

This looked like the perfect tool for my purposes - not a full email client, but a lightweight tool to intercept and show every mail that is sent my SharePoint 2013. The setup looked easy to. First I configured smtp4dev like this:

image

 

‘DEVSP2013’ was the local computer name of my VM. Now I configured SharePoint 2013, opened the Central Administration and jumped to the System Settings.

image

As you can see: I added the same machine name in smtp4dev and SharePoint - that’s important!

OK - now outbound mail should be configured, but how to test it? Because I only used local accounts these account did not have a mail address, although a mail address has been assigned to each user when the users have been added to the local AD.

image

So I first needed to assign valid mail addresses to my local demo users. This can be done using an application page and a few lines of code behind:

<%@ Page Language="C#" AutoEventWireup="true" Inherits="Microsoft.SharePoint.WebControls.LayoutsPageBase" DynamicMasterPageFile="~masterurl/default.master"  %>
<%@ Import Namespace="Microsoft.SharePoint" %>
 
<asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
 
</asp:Content>
 
<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<script runat="server">
   
    SPWeb myWeb = null;
    string message = string.Empty;
    string userName = string.Empty;
    public void Page_Load(object sender, EventArgs e)
    {
        myWeb = SPContext.Current.Web;
       
        message += "Welcome to " + myWeb.Title;
        message += "<br/><br/>This page was created with the minimal page directives required for SharePoint 2010 application pages...";
    }
    </script>
  
    <%
        message += "<br/><br/>Giving the users an e-mail address...<br/>";
 
        myWeb.AllowUnsafeUpdates = true;
       
        foreach (SPUser anUser in myWeb.AllUsers)
       {                     
            userName=anUser.Name.ToLower();
           
            if(!userName.Contains("system") && !userName.Contains("service"))
            {                       
                userName=userName.Remove(0,userName.IndexOf(@"\")+1);
                anUser.Email = userName + "@DEVSP2013.com";             
                anUser.Update();       
                message += "<br>" + anUser.Email + " was sucessfully attributed";         
            }           
       }
          
           lblMessage.Text = message;
    %>
 
      <asp:Label id="lblMessage" runat="server" />
    
</asp:Content>
 
<asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">
Set Users e-mail address
</asp:Content>
 
<asp:Content ID="PageTitleInTitleArea" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea" runat="server" >
Set users e-mail address
</asp:Content>

 

This piece of code simply adds a valid mail address to each user in the current web’s AllUsers collection. It’s true that this application page needs to be called each time a new user has been added to the local AD and it’s also true that this application page needs to be called for every web, but as this is a simple development environment this constraint is sufficient. To make calling this application page a little more convenient I placed a link in the Quick Launch of my demo Team Site :-)

After this application page has been opened and the code behind got executed all users got a valid mail address.

image

image

 

Finally I was able to test smtp4dev. The easiest way to force SharePoint to send a mail is to subscribe to a list to receive an alert. I used one of my local demo users to log on to SharePoint and subscribed to alerts on a list. Just after clicking OK the mails got intercepted by smtp4dev:

image 

Although this VM is not a fully functional SharePoint 2013 environment, it should be sufficient for using on a notebook locally and to do some SharePoint development or SharePoint live presentation - as long as any user of this VM knows about the limitations of using local user accounts (and of course the application page). I you need a lightweight SharePoint 2013 environment that can be used on a laptop - give a try to a single server installation with smtp4dev.

Add to Technorati Favorites Folge mir auf Twitter FourSquareLogo

Bereitgestellt 30 Mrz 2013 14:50 von Oliver Wirkus
Gespeichert unter: ,