This project is read-only.

Newsletter sends 10 emails then fails

Sep 17, 2010 at 8:32 PM


The newsletter widget sends email to 10 of our 100+ and fails for everyone after the initial 10.

I added the logging code to see what transpires. The 10 that are successfully sent all go to different domains?

Previously it would stop at 15 emails attempted until I switched of Asynchronous mailing.

Any help would be greatly appreciated!


Sep 18, 2010 at 12:32 PM

With the default SendMailMessageAsync, I tried this out on my local computer.  The first time I had 21 email addresses, and second time 42.  It was really the same 3 email addresses in the XML file multiple times (I manually edited).  On both attempts, I received all emails.

What you can try is to turn on logging.  Make sure on the Extensions tab that the Logger extension is enabled.  And then on the Settings tab in the control panel, under Advanced Settings, check "Enable error logging" -- if it's not already checked (it's unchecked by default).  With this checked, the Logger extension will create a file in the App_Data file named logger.txt (and keep appending to it) whenever code calls Utils.Log.

In the Newsletter widget (widget.ascx.cs), add the customized SendMailMessage function at the bottom of this post.  In the existing Post_Saved, change it so it calls SendMailMessage(mail); instead of Utils.SendMailMessage or Utils.SendMailMessageAsync.  By doing that, our customized SendMailMessage will get called instead.  The customized SendMailMessage calls Utils.Log() when an email is successful, as well as when it fails.  If you wanted, you could add an additional Utils.Log() call within the foreach loop in Post_Saved to log whether the MailMessage was created for each newsletter recipient.  If you did that, it would look like:

................ existing code in Post_Saved foreach loop ...........
................ existing code in Post_Saved foreach loop ...........

The above part is optional.  The customized SendMailMessage below is also calling Utils.Log as mentioned above.

After creating a new post and the Newsletter sends out the emails, check the logger.txt file in the App_Data folder.  You might have to wait a couple of minutes to allow the mail sending to finish before all the log records will appear.

private static void SendMailMessage(MailMessage message)
	if (message == null)
		throw new ArgumentNullException("message");

		message.IsBodyHtml = true;
		message.BodyEncoding = System.Text.Encoding.UTF8;
		SmtpClient smtp = new SmtpClient(BlogSettings.Instance.SmtpServer);
		// don't send credentials if a server doesn't require it,
		// linux smtp servers don't like that 
		if (!string.IsNullOrEmpty(BlogSettings.Instance.SmtpUserName))
			smtp.Credentials = new System.Net.NetworkCredential(
		smtp.Port = BlogSettings.Instance.SmtpServerPort;
		smtp.EnableSsl = BlogSettings.Instance.EnableSsl;
		Utils.Log("Email sent to: " + message.To[0].Address);
	catch (Exception ex)
		string msg = "Email failed: " + ex.Message;
		if (message != null && message.To.Count > 0)
			msg += ", email was to: " + message.To[0].Address;

		message = null;

Sep 20, 2010 at 11:14 PM


I have put the new SendMailMessage in place.

Our staff posts pretty often so would should get some results soon.

Thanks for taking the time to respond!


Sep 21, 2010 at 5:12 PM


Another post was created and exactly 10 emails were sent successfully. All others were logged as:

Email failed: Failure sending mail., email was to:

I read on another post where a previous version had a bug with sending emails.

I am took over the installation so I am not sure if there is somewhere I could check and see if old 1.4/1.5 code is still floating around.



Sep 21, 2010 at 6:56 PM

I added more information to the ex handling and am being hit with an:

Unable to read data from the transport connection.

This happens after 10 emails are sent. Is there something on the Exchange end I should be looking at?

Sep 22, 2010 at 2:12 PM

It's good that you were able to get some information.  Probably some of the extra details were in the InnerException which my code failed to look at :(

You're right that prior to 1.5, there was a problem where not all the emails would go out because of some faulty code -- that's been resolved.  I think that was just for Post Notifications when a new comment is left ... maybe it affected Newsletter emails too, can't remember.  I don't think you're affected by that since you're running BE 1.6.1.

As you may have found, that error message turns up a lot of hits on Google.  I think this error message doesn't exactly pinpoint the problem, but helps a little.

It could be a setting in Exchange.  I've not configured Exchange before, so I unfortunately can't help there.  I would suggest Googling for:

Unable to read data from the transport connection exchange

This search probably turns up more relevant hits when including the word "exchange".  This person said he resolved his issue and it had something to do with his Exchange server.  So you're probably correct that there is an Exchange level setting somewhere that will hopefully resolve this.  When I did my test, I was connecting to an SMTP server.

Sep 22, 2010 at 3:23 PM

Are you using your own mail server or one that came with an ISP account?

Its not uncommon for ISPs to throttle the amount of emails that can be sent in a burst so as to stop spammers abusing their services.


As a test I would introduce a random delay into the code or better yet contact your mail server admin and check if they have a limit like this in place.

Sep 23, 2010 at 4:46 PM

It is our own mail server. I tweaked some code and was able to get our test server sending the mail correctly. Now I am waiting on our staff to make a new post to see if the code changes worked.