This project is read-only.

newsletter problem

Topics: Controls
Jul 17, 2009 at 8:02 PM
hi ı am using BLOGENGİNE 1.5 but my newsletter doesnt work. is there any way to solve this problem ?
Jul 18, 2009 at 3:18 AM

What doesn't work?  Can you subscribe to the newsletter?  Are emails just not going out?

Jul 18, 2009 at 9:32 AM
ı am addinng email address but when ı add a new post its not sending email
Jul 18, 2009 at 10:03 AM

I had the same problem. Make sure your SMTP server allows relay from your web server. This was causing mine to not work. No error would be displayed. I had to debug into the SendMailMessage method in Utils.cs (BlogEngine.Core project). I was able to see the message about relay not being allowed when hovering over the SmtpException line. Enabling relay will vary from server to server, so check Google for yours.

Jul 18, 2009 at 10:08 AM
but in my contact page when ı write a new message it is sending ı is show that my SMTP working but newsetler widget doesnt. there is diffrent problem. are your widget works? can you give me your blog address

From: nodnarb
Sent: Saturday, July 18, 2009 12:03 PM
Subject: Re: newsletter problem [blogengine:62794]

From: nodnarb

I had the same problem. Make sure your SMTP server allows relay from your web server. This was causing mine to not work. No error would be displayed. I had to debug into the SendMailMessage method in Utils.cs (BlogEngine.Core project). I was able to see the message about relay not being allowed when hovering over the SmtpException line. Enabling relay will vary from server to server, so check Google for yours.

Jul 18, 2009 at 10:43 AM

When the newsletter emails are not sent, are you creating new blog posts, or editing existing blog posts?

The newsletter widget that comes with BE 1.5 will only send the newsletter emails when you're saving a new blog post, and the blog post is marked as "published".  If it is initially unpublished, and you later go back to publish it, the newsletter emails won't be sent out.

This behavior was changed after BE 1.5 was released.  You can try using the latest version of the Newsletter widget.  The only file that I believe changed was the Widget.ascx.cs file in the Widgets\Newsletter folder.  The latest version of that file is at:

You can try replacing the content of your Widget.aspx.cs file (in the Widget\Newsletters folder) with the content at the link above.

The main difference with the latest version is that the emails will be sent out whenever the blog post is going from an unpublished state to a published state.  So if you initially save the blog post as unpublished (to see how it looks, for example), and then later go back in to 'Publish it', even in this scenario, the newsletter emails will be sent out.

Jul 18, 2009 at 10:53 AM
ı changed all my newsetler but it still not sending email :( can ı send you my blog engine files
Jul 18, 2009 at 11:21 AM
it is giving this error Error 1 'BlogEngine.Core.Post' does not contain a definition for 'IsVisibleToPublic'
Jul 18, 2009 at 12:12 PM

You can download the latest version of BE on the Source Code tab above.  You'll need Visual Studio to compile the BE core project.

However, the latest version only has the added feature of sending newsletters when a post is going from an unpublished state to an published state.

With BE 1.5, if you create a new post and that post is marked as published, and the emails do not get sent out, then I don't believe the latest build of BE is going to make a difference.

With BE 1.5, if you create a new post and that post is published, do the Newsletter emails get sent out?

How many people are on your email list, btw?

Jul 18, 2009 at 12:14 PM
just 5
Jul 18, 2009 at 12:18 PM
and also ı published my post but ı didint get any mail can it be my hosting problem? but it is sending comment message to my mail. I download5 times my blog engine 1.5 ı am sure
Jul 18, 2009 at 12:34 PM

Have you checked the newsletter.xml file in the App_Data folder?   Is that where you see the 5 email addresses?

Jul 18, 2009 at 12:40 PM
yes ı cheked there is 5 person in this list ı thing this problems cause of my hosting company or maybe some preperties close. but interesting tkink is this is sending a mail for confirmation of comment but only newsetlerr not woking ı open link above ı download all project and ı run this witk vs 2008 it work. and ı confugure email setting then ı test ıt is succeful. ı add new post and publish but still newswtler didnt sen any message
Jul 18, 2009 at 12:48 PM

Does the Test email work on the Settings tab in the control panel?

How about the Contact page?  Does that work?

Jul 18, 2009 at 1:00 PM
yes it si working ı tested ı ı get success message yes contact also working ı send too many test message only problem in newsetler if you want ı can sen you my newsetler widget
Jul 18, 2009 at 1:09 PM

If your newsletter widget hasn't been changed since 1.5 was released, then I'm guessing it's okay.  You can post the contents of the widget.ascx.cs file here if you'd like.

One thing you can try is re-starting your blog application.  You can restart it by making any change in the web.config file (add a space in it, etc).  The newsletter email addresses are cached in memory.  Although it's doubtful, there could be a problem with the email addresses in memory.  If you re-start the blog application, BE will re-read the newsletters.xml file -- getting the latest version of that file.

Jul 18, 2009 at 1:18 PM
but in local host every time ıam creating new project and after debuging and ı confugure mail setting all my contack and comments mail working but newsetler doesnt ı will try to remave my procekts in my host and then ı put new one here is the my code #region using using System; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.IO; using System.Xml; using BlogEngine.Core; using System.Net.Mail; #endregion public partial class widgets_Newsletter_widget : WidgetBase, ICallbackEventHandler { public override string Name { get { return "Newsletter"; } } public override bool IsEditable { get { return true; } } public override void LoadWidget() { } #region Event handling static widgets_Newsletter_widget() { Post.Saved += new EventHandler<SavedEventArgs>(Post_Saved); } and also <%@ Control Language="C#" AutoEventWireup="true" CodeFile="widget.ascx.cs" Inherits="widgets_Newsletter_widget" %>

Get notified when a new post is published.

<label for="<%=txtEmail.ClientID %>" style="font-weight:bold">Enter your e-mail</label>
<asp:TextBox runat="server" ID="txtEmail" Width="100%" /> <asp:RequiredFieldValidator runat="server" ControlToValidate="txtEmail" ErrorMessage="Please enter an e-mail address" Display="dynamic" ValidationGroup="newsletter" /> <asp:RegularExpressionValidator runat="server" ControlToValidate="txtEmail" ErrorMessage="<%$Resources:labels, enterValidEmail %>" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" Display="dynamic" ValidationGroup="newsletter" />
<asp:Button runat="server" ID="btnSave" ValidationGroup="newsletter" Text="Notify me" OnClientClick="return beginAddEmail()" />

Thank you

<script type="text/javascript"> function beginAddEmail() { if(!Page_ClientValidate()) return false; var arg = BlogEngine.$('<%=txtEmail.ClientID %>').value; var context = 'newsletter'; <%=Page.ClientScript.GetCallbackEventReference(this, "arg", "endAddEmail", "context") %>; return false; } function endAddEmail(arg, context) { BlogEngine.$('newsletterform').style.display = 'none'; BlogEngine.$('newsletterthanks').style.display = 'block'; if (arg == "false") { BlogEngine.$('newsletteraction').innerHTML = "You are now unsubscribed"; } } </script> static void Post_Saved(object sender, SavedEventArgs e) { Post post = (Post)sender; if (e.Action == SaveAction.Insert && post.IsPublished) { LoadEmails(); foreach (XmlNode node in _Doc.SelectNodes("emails/email")) { MailMessage mail = CreateEmail(post); mail.To.Add(node.InnerText); Utils.SendMailMessageAsync(mail); } } } private static MailMessage CreateEmail(Post post) { MailMessage mail = new MailMessage(); mail.Subject = post.Title; mail.Body = "There'a new post available.
" + post.Title + "
"; mail.Body += post.Description; mail.Body += "
"; mail.Body += "You receive this e-mail because you have signed up for e-mail notifications at "; mail.Body += "" + Utils.AbsoluteWebRoot + ""; mail.From = new MailAddress(BlogSettings.Instance.Email, BlogSettings.Instance.Name); return mail; } #endregion #region Save and retrieve e-mails private static XmlDocument _Doc; private static string _FileName; private void AddEmail(string email) { try { LoadEmails(); if (!DoesEmailExist(email)) { XmlNode node = _Doc.CreateElement("email"); node.InnerText = email; _Doc.FirstChild.AppendChild(node); _Callback = "true"; SaveEmails(); } else { _Doc.FirstChild.RemoveChild(_Doc.SelectSingleNode("emails/email[text()='" + email + "']")); _Callback = "false"; SaveEmails(); } } catch { _Callback = "false"; } } private bool DoesEmailExist(string email) { return _Doc.SelectSingleNode("emails/email[text()='" + email + "']") != null; } private static void LoadEmails() { if (_Doc == null || _FileName == null) { _FileName = Path.Combine(BlogSettings.Instance.StorageLocation, "newsletter.xml"); _FileName = System.Web.Hosting.HostingEnvironment.MapPath(_FileName); if (File.Exists(_FileName)) { _Doc = new XmlDocument(); _Doc.Load(_FileName); } else { _Doc = new XmlDocument(); _Doc.LoadXml("<emails></emails>"); } } } private void SaveEmails() { using (MemoryStream ms = new MemoryStream()) using (FileStream fs = File.Open(_FileName, FileMode.Create, FileAccess.Write)) { _Doc.Save(ms); ms.WriteTo(fs); } } #endregion #region ICallbackEventHandler Members private string _Callback; /// <summary> /// Returns the results of a callback event that targets a control. /// </summary> /// <returns>The result of the callback.</returns> public string GetCallbackResult() { return _Callback; } /// <summary> /// Processes a callback event that targets a control. /// </summary> /// <param name="eventArgument">A string that represents an event argument to pass to the event handler.</param> public void RaiseCallbackEvent(string eventArgument) { _Callback = eventArgument; AddEmail(eventArgument); } #endregion }
Jul 18, 2009 at 2:08 PM
now it is ok but this time it is sending only one adress it is not sending email to windowslive or gmail it is sending mail only my domains mail
Jul 19, 2009 at 12:09 AM

If it's only sending email to the same domain name that you're using for the From address (i.e. to, that could be because of misconfigured email settings on the Settings tab in the control panel.

I would review the email settings you have in there.  I've seen before where if you are using an invalid Username/Password (for SMTP authentication), then a mail server might deliver intra-domain email, but not deliver email outside of the server.

You can ask the support department at your web hosting company what SMTP settings you should be using -- SMTP server name, Port Number, SMTP Auth Username, SMTP Auth Password, Enable SSL.

Jul 19, 2009 at 12:29 PM
BENAMANDA THANK YOU FOR YOUR HELP . in monday ı will contact my hosting company to solve my email problem.
Nov 9, 2009 at 2:46 AM

I am having athe same problem.  with 1.5.  In 1.4.7 it worked fine but now it will only send to same domain addresses.  My list is small and the settings are the same for the smtp host. 

Also it would not send comments nor comment notifications to admin nor to users for replies.  I got the comments working by reading a different post. 

I seen another post about comments and credentials and made the change the suggested and got the admin comment notification but I do not have user notification for replies.  Tomorrow I will be doing another post and see if anything changed there. 

Now my host does not require credentials if I am sending it from the the web server to the mail server.  I added credentials to get the above checnge to work because after looking at the code I realized that it only took place if there were credentials. Later I will try to move the fix to outside the if statement and remove my credentials and see if I still have that part.  But so far I have not seen a new post email to a non-domain address from ver 1.5

Nov 19, 2009 at 11:50 AM
Edited Nov 19, 2009 at 12:29 PM


 I also have some obstical with my newsletter!  By torrent search engine  you can get more useful information, files and programms which help to solve your prodlems!