This project has moved and is read-only. For the latest updates, please go here.

Error sending email

Jun 3, 2011 at 5:47 PM

I have installed everything just fine and am able to add the Membership Request webpart. However, when I try to create a new user, I receive an error message and the following entry is in my logs:

System.Exception: Error sending mail notification at Visigo.Sharepoint.FormsBasedAuthentication.MembershipRequest.ApproveMembership(MembershipRequest request, SPWeb web)

I have no problem receiving outgoing emails from my site, as I have tested this with a notification. What am I missing?

Jun 3, 2011 at 6:03 PM

Make sure that the email settings are set both under Central Administration -> Outgoing Email settings, as well as on the Manage Web Applications screen.

If they are both set properly and you are still having problems, check the SharePoint log file and search for "SendEmail failed" - there should be a more detailed exception logged just before it.

Jun 3, 2011 at 6:05 PM
Edited Jun 3, 2011 at 6:08 PM

You may need to add the mailsettings info to your web.config of the FBA site. Here's what I have in my config:

      <smtp deliveryMethod="Network" from="email address">
        <network host="email server" port="25" />

This is a child of the <configuration> tag.

-- Travis Trout

Jun 3, 2011 at 7:00 PM

Travis - I have added that to my web.config and it is still not working.

ccoulson - I have both settings working correctly.  I am still getting an error and seeing the log entries.  Here are the actual two entries that I see:

06/03/2011 13:53:39.22  w3wp.exe (0x1AE8)                        0x2B64 SharePoint Foundation          Runtime                        tkau Unexpected System.Exception: Error sending mail notification    at Visigo.Sharepoint.FormsBasedAuthentication.MembershipRequest.ApproveMembership(MembershipRequest request, SPWeb web)     at Visigo.Sharepoint.FormsBasedAuthentication.MembershipRequestControl.<>c__DisplayClass2.<OnCreatedUser>b__0()     at Microsoft.SharePoint.SPSecurity.<>c__DisplayClass4.<RunWithElevatedPrivileges>b__2()     at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode)     at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param)     at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode)     at Visigo.Sharepoint.FormsBasedAuthentication.MembershipRequestControl.OnCreatedUser(EventArgs e)     at System.Web.UI.... c14b1faa-1304-477c-9fd4-87f453ba7fd2

06/03/2011 13:53:39.22* w3wp.exe (0x1AE8)                        0x2B64 SharePoint Foundation          Runtime                        tkau Unexpected ...WebControls.CreateUserWizard.AttemptCreateUser()     at System.Web.UI.WebControls.CreateUserWizard.OnNextButtonClick(WizardNavigationEventArgs e)     at System.Web.UI.WebControls.Wizard.OnBubbleEvent(Object source, EventArgs e)     at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)     at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)     at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) c14b1faa-1304-477c-9fd4-87f453ba7fd2

I reviewed the Sharepoint logs at c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Logs for the "SendEmail failed" and there is no entry.  I then searched for just SendEmail and there is no entry.  Any additional information you may have would be greatly appreciated.

Jun 3, 2011 at 7:55 PM

Usually the error can mean one of two things: There's something wrong with the SharePoint setup so it can't send the email (it uses the built in SharePoint method for sending email SPUtility.SendEmail), or there was a problem creating the email from the XSLT template (However I would have expected additional items in the log file if there were errors with the templates).  But check that the template files set in 'FBA Site Configuration' actually do exist, and are the original templates installed with the FBA Pack (in case changes to the templates have caused the error).  

Jun 3, 2011 at 8:04 PM

The MembershipApproved.xlst file is in the location c:\program files\common files\microsoft shared\web server extensions\14\template\layouts\fba\emails directory and is the original file, so that's not it.  Is there anyway I can get additional information from this exception?  I've turned on tracing at the Verbose level and it did not give me any additional information.  Is there anyway I can test the SPUtility.SendEmail function by itself?

Jun 3, 2011 at 8:12 PM

It calls another built in SharePoint method: SPUtility.IsEmailServerSet() - if that returns false then all you'll get is the exception you've been getting.  If it proceeds past that point, you should be getting some additional entries in the log file.  

If you have Visual Studio, you can pretty quickly write a small simple program that calls IsEmailServerSet and SendEmail. (Or you could use it to debug the FBA Pack and see what's going on).

Jun 4, 2011 at 2:35 PM

I agree - it's failing on IsEmailServerSet.  I setup another instance of Sharepoint on my laptop and completed the exact same config, using the same ASP.Net database and it worked just fine.  So, I know it's not authorizations.  Any idea what the code of IsEmailServerSet checking and where I can get more information?

Jun 4, 2011 at 2:36 PM

And yes, I have Visual Studio 2010, but I don't know how to debug a Sharepoint runtime object.

Jun 4, 2011 at 9:56 PM

I reflected the code on IsEmailServerSet, and it calls this on the WebApplication:

internal bool IsEmailServerSet
        SPOutboundMailServiceInstance outboundMailServiceInstance = this.OutboundMailServiceInstance;
        return outboundMailServiceInstance !null && !string.IsNullOrEmpty(outboundMailServiceInstance.Server.Address);

So it looks like it's essentially checking the email settings that are set on the web application.  Maybe try and go into Manage Web Applications -> Outgoing Email Settings and try and change the settings, and then go back in and change them back. Maybe that will fix whatever problem there is with the setup?

As for how to debug, just grab the source code from codeplex, open it in visual studio and deploy to your server (You'll have to specify the server in the project properties).  Then just set breakpoints and start debugging.

Jun 10, 2011 at 7:43 PM

I have deleted my SMTP entries on the Farm and on the Web Application and added them back.  I still have no problems receiving alerts, but still receive the error when trying to create the user.

As far as how to debug - the solution is on my test server and my VS2010 is on my laptop.  I can't figure out how to be able to debug remotely.

Jun 10, 2011 at 9:11 PM

I've never debugged remotely (it's sounded like a real pain to get working).  I'd say save yourself the trouble and install VS 2010 on the test server.  If you do want to try and debug remotely though, I did find this blog entry:

Jun 11, 2011 at 1:24 AM

I installed VS2010 on my test server, grabbed the code from codeplex, changed the Site URL in the Project Properties to my site and then click on Build -> Deploy; however, I received the error "Error occurred in deployment step 'Retract Solution':  Attempted to perform an unauthorized operation.'  Any ideas?

Jun 11, 2011 at 1:28 AM

Disregard last post - I was able to fix it by giving my logon user Full access at the Web Application level.

Jun 11, 2011 at 3:06 AM

Well - just to let you know - the problem is fixed.  Unfortunately, I have no idea how.  I installed VS 2010 on my test server, deployed the solution, put a breakpoint where I thought it would error, and it miraculously completed without errors.  I wish I had a clue as to what fixed it, but I don't.

Jun 11, 2011 at 3:11 AM

That is very strange.  Maybe try redeploying the package downloaded from the website and see if the problem returns?

Jun 15, 2011 at 4:19 AM

I redeployed the solution and am receiving the error again.  I was able to successfully debug and found the error to be at the following line of code:


The ex variable (Exception) contains the following message:  "The underlying connection was closed:  Could not establish trust relationship for the SSL/TLS secure channel."

My website is using SSL - but, I'm not quite sure what this means?

Jun 15, 2011 at 5:07 AM

Very strange. My guess is that it has something to do with how the address to the template file is built:

string.Format("{0}{1}", web.Url, settings.MembershipApprovedEmail)

Maybe web.Url is returning an http instead of https url.

Or potentially the setting for the location of the email template is incorrect (the setting is stored with the web, so it is not reset during a redeploy). For Membership Approved it should be set to:


Check the screen shots in the documentation for all of the values.

Jun 15, 2011 at 5:09 AM

Also, does it work fine if you don't use ssl to access the site?

Jun 15, 2011 at 1:52 PM

The value of string.Format("{0}{1}", web.Url, settings.MembershipApprovedEmail is correctly set to https://{mysite}/_layouts/FBA/emails/MembershipApproved.xslt and the xslt file is located in the directory C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\FBA\EMAILS.

I will extend my site and turn off SSL to test that way and see if it works.  Additionally, the InnerException of the message is "The remote certificate is invalid according to the validation procedure".  I'm not quite sure how this could be, as I'm using my domain certificate which is issued by GoDaddy.

Jun 15, 2011 at 4:09 PM

I extended the site to port 80, and the functionality works fine without SSL.

Jun 16, 2011 at 1:46 AM

Ok - I finally found out what the problem was.  Apparently Sharepoint has it's own Certificate store, and my CA's Trusted Root certificate was not in there - thus, it wasn't trusting the connection.    I found an article that helped (  To fix it on my server, I created a new directory called certs and downloaded the GoDaddyTrustedRoot.cer file into it.  I then opened a Windows Powershell and executed the following commands:

Add-PSSnapin Microsoft.SharePoint.PowerShell

$rootca = New-Object System.Security.Cryptography.x509Certificates.x509Certificate2(“c:\certs\GoDaddyTrustedRoot.cer”)

New-SPTrustedRootAuthority –Name “GoDaddy Root CA” –Certificate $rootca

After running an IISRESET, everything is working fine.

Jun 16, 2011 at 3:29 AM

EXCELLENT! I was afraid there might be some problem opening a file via SSL with xslEmailTransform. Glad to see you got it figured out.

Sep 21, 2011 at 4:26 PM

I had the same certificate issue as tbarber and wanted to expand on the solution in case it helps others searching for the answer. My site is set up using SSL and my log showed the same errors, pasted here for search engines:

An operation failed because the following certificate has validation errors:
The root of the certificate chain is not a trusted root authority.
System.Net.WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.
at Visigo.Sharepoint.FormsBasedAuthentication.Email.SendEmail(SPWeb web, String emailTo, String xsltTemplateFile, IDictionary xslValues)
SendEmail failed
System.Exception: Error sending mail notification     at Visigo.Sharepoint.FormsBasedAuthentication.MembershipRequest.ApproveMembership(MembershipRequest request, SPWeb web)

I followed the steps to add the certificate via PowerShell, but still had the problem. Then I saw this article on Technet about multiple certificates in the path:

I checked mine and sure enough, there were two additional "parent" certificates above mine. By this time I had run across another blog post that detailed how to add the certificate through Central Administration:

I exported my two additional certificates and added them through Central Admin, and without needing to do IISRESET, the Approval and Rejection emails from the Membership Request list immediately started working.

Thank you tbarber for your documentation on the fix. I'm sure I'll be back here next year when the certificate expires and emails stop going out :)

Mar 28, 2012 at 6:35 PM
ttrout wrote:

You may need to add the mailsettings info to your web.config of the FBA site. Here's what I have in my config:

      <smtp deliveryMethod="Network" from="email address">
        <network host="email server" port="25" />

This is a child of the <configuration> tag.

-- Travis Trout

Just a note that adding this can cause some issues with how the FBA Pack works.  The emails will be sent directly by the membership controls, instead of by the FBA Pack using the xslt templates.  The FBA Pack should work using SharePoint's email settings. If you are using an SSL Certificate, the root of that certificate needs to be trusted by SharePoint: Central Admin -> Security -> Manage Trust.

Apr 23, 2012 at 2:47 PM

I was getting an error when the library try to send any email in my SSL Web Application (with Windows authentication). If I extend to a 80 port, it worked ok.

My problem was that my SSL Web Application is configured in IIS to require a Cliente Certificate. It cause thar the FBA library not could read the xslt template when execute the function "xslEmailTransform.Load" (error 404).

The solution, in my case, was disable the requierement of Client Certificate in IIS for the "/_layouts/FBA/emails" folder.

Aug 26, 2012 at 6:41 PM


I had a similar issue as above and after weeks of troubleshooting finally found my issue. I had the FBA pack working 100% in dev but no matter what i tried couldn’t get it to work in Prod. Was getting an exception

"System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond "when it tried to load the XSLT.

The solution for me included the certificate issue above but also was related to the DNS IP address. Our site is NAT'ed behind a firewall and the IP of the server is not the same as the public IP. The IP that the code had gotten was the External IP. Then it clicked, on Dev i had added local host entry’s to test access to the site (hence local DNS IP to After a quick change on production to test, registration and other email related controls worked first time.

With a temporary fix in place, I now need to find something a bit more unwavering.

Hopefully this helps someone else.

Aug 27, 2012 at 2:41 AM

Just an FYI, as of version 1.3, the xslt/ssl loading errors should no longer be happening due to a change in the way the xslt is loaded.