Problem with notifications in 1.4

Topics: Business Logic Layer
Jul 6, 2008 at 6:58 AM
I'm not getting notification emails when someone adds a comment in my blog, even though the settings are the same as before migrating, and the "test" button works perfectly.

Anybody else is having this problem?

Thanks
Jul 6, 2008 at 8:15 AM
Hi. I have the same problem and I have just installed the new version but the same problem continues. Also I cannot login with new users?!!!!!
I think it is the problem of all users.
Anybody can help?!!!!!!!!!!!
Jul 8, 2008 at 2:32 PM
Edited Jul 8, 2008 at 5:29 PM
Any ideas on this?
It worked ok in the last version...

EDIT: Hmm... the code formatter extension also doesn't work, it may be a problem with extensions in general.
Jul 8, 2008 at 8:36 PM
Well, I saw that extensions were loaded in the application_start in the global.asax, and that was my problem... for some reason, the method wasn't being called on my hosting server... I tested it copying the code to an aspx page and calling it explicitly, and that was it... extensions loaded and started to work again...

Jul 8, 2008 at 9:54 PM
Hey guys,

I used the original extension code to do my own mail sender, hard coded. I guess the problem with the original is that it is checking the profiles funcionality, which is not working, but I don't know for sure.
Anyway, here is the code, you may use it and modify any way you want:
It is tested on Godaddy only.

Cheers,

Giovanni Bassi
http://unplugged.giggio.net





#region using

using System;
using System.Web;
using BlogEngine.Core.Web.Controls;
using BlogEngine.Core;
using System.Net.Mail;
using System.Threading;

#endregion

/// <summary>
/// Sends an e-mail to the blog owner whenever a comment is added.
/// </summary>
[Extension("Sends an e-mail to the blog owner whenever a comment is added", "1.4", "BlogEngine.NET")]
public class SendCommentMailGiggio
{

/// <summary>
/// Hooks up an event handler to the Post.CommentAdded event.
/// </summary>
public SendCommentMailGiggio()
{
Post.CommentAdded += new EventHandler<eventargs>(Post_CommentAdded);
}

private void Post_CommentAdded(object sender, EventArgs e)
{
Post post = (Post)((Comment)sender).Parent;
if (post != null)
{
Comment comment = post.Comments[post.Comments.Count - 1];
// Trackback and pingback comments don't have a '@' symbol in the e-mail field.
string from = comment.Email.Contains("@") ? comment.Email : "giggio@giggio.net";
string subject = " comment on ";

if (comment.Email == "trackback")
subject = " trackback on ";
else if (comment.Email == "pingback")
subject = " pingback on ";

ServingEventArgs args = new ServingEventArgs(comment.Content, ServingLocation.Email);
Comment.OnServing(comment, args);
string body = args.Body;

MailMessage mail = new MailMessage();
mail.From = new MailAddress(from, HttpUtility.HtmlDecode(comment.Author));
mail.To.Add("giggio@giggio.net");
mail.Subject = BlogSettings.Instance.EmailSubjectPrefix + subject + post.Title;
mail.Body = "
";
mail.Body += body.Replace(Environment.NewLine, "
") + "

";
mail.Body += string.Format("{0}: {2}

", Resources.labels.post, post.PermaLink + "#id_" + comment.Id, post.Title);

mail.Body += "_______________________________________________________________________________
";
mail.Body += "

Author information

";
mail.Body += "
";
mail.Body += "Name: " + comment.Author + "
";
mail.Body += "E-mail: " + comment.Email + "
";
mail.Body += string.Format("Website: {0}
", comment.Website);

if (comment.Country != null)
mail.Body += "Country code: " + comment.Country.ToUpperInvariant() + "
";

if (HttpContext.Current != null)
{
mail.Body += "IP address: " + HttpContext.Current.Request.UserHostAddress + "
";
mail.Body += string.Format("Referrer: {0}
", HttpContext.Current.Request.UrlReferrer);
mail.Body += "User-agent: " + HttpContext.Current.Request.UserAgent;
}

mail.Body += "
";
mail.Body += "
";


mail.IsBodyHtml = true;
mail.BodyEncoding = System.Text.Encoding.UTF8;



SmtpClient client = new SmtpClient("relay-hosting.secureserver.net");
client.Port = 25;
client.EnableSsl = false;
client.Send(mail);

//Utils.SendMailMessageAsync(mail);
}
}

}


</eventargs>