E-mail help please and thank you

Oct 21, 2008 at 8:15 PM

Hello everyone first I want to say thanks for offering blog engine. This is my first blog that I have ever used and I love it. Very simple and looks great. Plus it has a lot of useful options.

 

OK I am running Powered by BlogEngine.NET 1.4.5.0  On my site www.ourfitnessjourney.com and everything works great but the E-mail? For some reason I cannot seem to get it figured out. It will not connect. I am using Go Daddy as my host and the blog was installed using their service.

 

I am sure it is just a setting that I cannot figure out. I called Go Daddy to get the SMTP server information and the port number. They said the port number was 80, and I cannot remember what two server names they gave me to try but neither of them worked? It will not connect and send the test e-mail. Is there anything else that I can do? Please and thank you.

 

Chris

Oct 22, 2008 at 9:20 AM
80 does not sound right for SMTP. I thought Godaddy used standard smtp or maybe secure. Not sure. Anyway if you go to their support site you should be able to find info on using GD with Outlook. The mail server and port you will use are the same for Outlook (outgoing) and your username and pass you should know.
Oct 22, 2008 at 2:08 PM
Edited Oct 22, 2008 at 2:10 PM
Taylex,

Thanks for the help, I was able to get some one from Go Daddy that helped me out. Well she googled it and found ouy :)

Enter 
relay-hosting.secureserver.net  as the server name

port is left at 25 default

usename is left blank

password left blank

and un check enable SSL

BAM IT WORKED :)
Oct 22, 2008 at 3:49 PM
Ok well I see to have another issue now? LOL it's never ending.

When I click the test e-mail with the above settings I get a confiamtion e-mail sent to the e-mail address that I provided so I know that it is working.

However if I click the contact link at the top of my blog and then fill out the information and send a message I never get the E-mail? I have sent several test e-mails and none of them have gone through?

Any advice?

THanks
Oct 22, 2008 at 5:05 PM
When you click the send button. does it show you the Thank you message or does it just show the email form again?
Oct 22, 2008 at 5:50 PM
It shows the "The message was sent" when I click the button, Not sure why I am not getting the E-mail?

here is the link to the e-mail contact page

http://www.ourfitnessjourney.com/ourfitnessjourney/contact.aspx

Thanks for the help

Chris
Oct 22, 2008 at 10:20 PM
I found that updating the test email code (admin\Pages\Settings.aspx.cs) to render the exception details very helpful. Getting a generic failure message doesn't help you figure out what you need to fix.

If you ever get problems sending emails (with the error message displayed), give this a go. The two changes are in bold.

    private void btnTestSmtp_Click(object sender, EventArgs e) {
        try {
            MailMessage mail = new MailMessage();
            mail.From = new MailAddress(txtEmail.Text, txtName.Text);
            mail.To.Add(mail.From);
            mail.Subject = "Test mail from " + txtName.Text;
            mail.Body = "Success";
            SmtpClient smtp = new SmtpClient(txtSmtpServer.Text);
            smtp.Credentials = new System.Net.NetworkCredential(txtSmtpUsername.Text, txtSmtpPassword.Text);
            smtp.EnableSsl = cbEnableSsl.Checked;
            smtp.Port = int.Parse(txtSmtpServerPort.Text, CultureInfo.InvariantCulture);
            smtp.Send(mail);
            lbSmtpStatus.Text = "Test successfull";
            lbSmtpStatus.Style.Add(HtmlTextWriterStyle.Color, "green");
        } catch (Exception ex)
        {
       
            lbSmtpStatus.Text = "Could not connect - " + ex.ToString();
            lbSmtpStatus.Style.Add(HtmlTextWriterStyle.Color, "red");
        }
    }
Oct 25, 2008 at 9:19 PM
hello, i have the same problem, if i send a test message, it works. but if i make a comment or send a message with the contact form no message arrived me. could anybody help me pls..?
Dec 4, 2008 at 1:10 AM
I too am experiencing this exact same behavior.
Dec 10, 2008 at 3:16 PM
Hi,

I was setting up my email in a new blog installation. I have GoDaddy as my ISP.

I was able to get it working by using the settings suggested above by LifeCatcher, except that I also used my account user name and password. So, I think that to get the "contact" feature working, you probably need to enter your GoDaddy user name and password (not your blog user name and password that you set up on GoDaddy when you installed the blog software, but rather your hosting account user name and password). It worked for me.

Kind Regards,

saratogacoach
Jan 10, 2009 at 7:16 PM
Hi,
I just ran into the same issue. 
The relay I use for outlook godaddy domain mail is smtpout.secureserver.net.
However, this does not work.

I used the relay-hosting.secureserver.net with no ssl and it worked perfectly.

Thanks for the info.

D. Beard

Jan 20, 2009 at 3:36 PM

HELP

I used the relay-hosting.secureserver.net with no ssl and it worked perfectly also

BUT contact form doesnt SEND the email...for the contact form...the message never arrives, the email works fine and is hosted at godaddy for same domain account...

other guy wrote---
"So, I think that to get the "contact" feature working, you probably need to enter your GoDaddy user name and password (not your blog user name and password that you set up on GoDaddy when you installed the blog software, but rather your hosting account user name and password). It worked for me."

what user name the main Godaddy account..? I used that it still doesnt arrive in the inbox...Why is this so difficult..??  can someone reply that has actully set it up correct and has coantact form messages ariving in inbox...thanks...

everything works except for the contact form meesage not ariving in inbox...everything is at godaddy....

G
Jan 20, 2009 at 3:46 PM
I wrote a short blog post on this at DotNetBlogger.com
Jan 20, 2009 at 5:47 PM
thanks but that threw an error...i have version   Powered by BlogEngine.NET 1.4.5.0

i will look at the code more....any ideas would be great....this is taking way too much of time...
Coordinator
Jan 20, 2009 at 6:46 PM
If you can receive a test email on the Settings tab in the control panel, but the Contact page emails are not being received, the solution for this is usually to remove or comment out the lines in the contact.aspx.cs file:

mail.ReplyTo = new MailAddress(email, name);
mail.Sender = mail.ReplyTo;

I'd first try just commenting out the mail.Sender line ...

mail.ReplyTo = new MailAddress(email, name);
//mail.Sender = mail.ReplyTo;

If it still doesn't work, then try commenting out both lines ...

//mail.ReplyTo = new MailAddress(email, name);
//mail.Sender = mail.ReplyTo;
Jan 24, 2009 at 11:27 PM
@BenAmada

That worked for me, thanks! Now if only I could find where to make the same type of change for the comment notification ...
Coordinator
Jan 24, 2009 at 11:50 PM
The code for comment notification emails is in App_Code\Extensions\SendCommentMail.cs.

But I just looked at that code, and if you're not getting comment notification emails, the problem is probably a little different.  There is no "mail.ReplyTo" or "mail.Sender" in this code.  My guess would be the problem is with the line below:

mail.From = new MailAddress(from, HttpUtility.HtmlDecode(comment.Author));

The "From" email address is contained in the "from" variable which is defined a little higher in the code:

string from = comment.Email.Contains("@") ? comment.Email : BlogSettings.Instance.Email;

The problem, I *think* is that the From email address is being set to the email address of the person leaving the comment.  In a lot of hosting environments this isn't allowed since the "From" email address has to be your own email address.  You can't make the From address someone else ... this is spoofing.  So, I'd try changing that line above to:

string from = BlogSettings.Instance.Email;

This will make the From email address the email address you have in the Settings tab in the control panel.  Then if you want, you could optionally try adding a ReplyTo line so if the email recipient (i.e. the notifiee) decides to reply to the notification, they will reply to the commenter instead of replying to you.

msg.ReplyTo = new MailAddress(comment.Email.Contains("@") ? comment.Email : BlogSettings.Instance.Email);
Jan 25, 2009 at 12:09 AM
@BenAmada

Once again, you are right. Thanks for being my BlogEngine.NET guru.

Here's something else I discovered looking at SendCommentMail.cs: it won't send the email if you're logged in.  So make sure you're logged out when testing your comment notifications.
Feb 19, 2009 at 6:49 AM
Alright, I got everything with email working but the "<label style="width: auto; float: none; display: inline;" for="cbNotify">Notify me when new comments are added</label>" is checked but the commenter is not receiving email notification when new comments are added. Only I receive the notification of any new comments added.
Coordinator
Feb 19, 2009 at 4:15 PM
I just looked at the code in BE for that.  It looks like comment notification emails are sent out to people who have signed up for comment email notification once the comment has been approved (if moderation is turned on).  Do you have moderation turned on?  If so, after approving the comment, notifications are still not being sent out?  If you don't have moderation on, then it looks like the comment notification emails should get sent out right away.

The problems discussed in this thread with the "From" address and "Sender" address being set to email addresses not administered by the mail server doesn't appear to be an issue with comment notification emails.  For comment notification emails, the "From" address is set to the email address on the Settings tab in the control panel, and the "To" address is set to the people who requested comment notification emails.
Feb 19, 2009 at 4:30 PM
moderate comments is not checked. I did a test with one of my email address, posted comment and checked "be notified of new comments". Then I posted another comment in same article under a different email address and the first email address did not get the new comment notification.

what works are
1. contact page
2. admin notified when new comment made

these work thanks to you (BenAmanda), very much.
Coordinator
Feb 19, 2009 at 5:28 PM
It seems you stumbled onto a problem in BE.  I looked into it some more and realized that comment notification emails are never sent out if comment moderation is turned off.

I just created this issue in the issue tracker for this.  I included the code needed to fix the problem.  However, the code I put in the issue involves making a change in a BE core file.  If you don't mind doing that and re-compiling the BE core, you're welcome to do that.

If you don't want to modify the BE core, what you can do is modify the CommentView.ascx.cs file in the User Controls folder.  In that file, you'll see the code below.  If you add the part in bold, that should send comment notification emails whenever a comment is left if moderation is turned off.

if (!isPreview)
{
    Post.AddComment(comment);

    if (comment.IsApproved)
        Post.ApproveComment(comment);


    SetCookie(author, email, website, country);
}

P.S.  If you want, feel free to vote for the issue so it is fixed for everyone in the near future.
Feb 19, 2009 at 5:56 PM
Thanks again, it works. I added the code like you said for CommentView.ascx.cs file. Amazing skills you have. I will vote for the fix.
Feb 19, 2009 at 8:39 PM
I think there's still an issue here BenAmada. I used your solution in the BE Core which sends out the e-mails fine, but only to the last commenter.

I'm using 4 different e-mails (one of which is the admin account) and each time I make a comment with different 'users', I get the admin notification and a copy to the previous poster only. EG

1st Post made by John
2nd Post made by Lisa
3rd Post made by Tom
4th Post made by Amy

As you go through each stage only the previous poster gets a copy. So when Lisa posts, John gets notified. When Tom posts Lisa gets notifies but not John....when Amy posts Tom gets notified but Lisa and John dont.
In each stage the admin still gets a copy.

I can't figure this out? All the e-mail address are present and valid in the posts xml file.

Feb 19, 2009 at 8:49 PM
I just noticed something. Say I am John, I do get notified when Amy post but the email in the To field is written to the other person's email address, but the email is coming to me....very weird.
Coordinator
Feb 19, 2009 at 8:55 PM
rpsitehp: Does the subject of the email start with "Weblog comment on"?  Or does it start with "New comment on"?

If the subject starts with "Weblog comment on", then that is the email sent to the administrator whenever someone leaves a comment.  It's not the email sent out for comment notifications.  This email with a subject beginning with "Weblog comment on" is an extension called "SendCommentMail" that can be found on the Extensions tab in the Control Panel.
Feb 19, 2009 at 8:57 PM
The subject is "New Comment On...."
Feb 19, 2009 at 9:04 PM
Also the email is sent twice, same copy
Coordinator
Feb 19, 2009 at 9:28 PM
rpsitehp and beansontoast:

I was able to track down and reproduce the problem beansontoast reported.  I'm pretty sure its the same problem you are running up against, rpsitehp.  I just created this issue for this problem in the issue tracker.

I posted a solution in the issue.  The solution involves modifying the BE core code.

rpsitehp, if you don't want to or can't modify the BE core code, I put together something you can use to solve this.  The code is below.  It's the same code we changed before in CommentView.ascx.cs, but we no longer need the part we added earlier today because the code below is going to send notifications itself.  So if you use the code below, then you should remove that other part we added earlier.

if (!isPreview)
{
    Post.AddComment(comment);

    if (comment.IsApproved && Post.NotificationEmails.Count > 0)
    {
        foreach (string recipient in Post.NotificationEmails)
        {
            if (recipient != comment.Email)
            {
                System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();

                mail.From = new System.Net.Mail.MailAddress(BlogSettings.Instance.Email, BlogSettings.Instance.Name);
                mail.Subject = "New comment on " + Post.Title;
                mail.Body = "Comment by " + comment.Author + "<br /><br />";
                mail.Body += comment.Content.Replace(Environment.NewLine, "<br />") + "<br /><br />";
                mail.Body += string.Format("<a href=\"{0}\">{1}</a>", Post.PermaLink + "#id_" + comment.Id, Post.Title);

                mail.To.Add(recipient);
                Utils.SendMailMessageAsync(mail);
            }
        }
    }

    SetCookie(author, email, website, country);
}
Feb 19, 2009 at 9:56 PM
BenAmada, you are a god! I use the source code solution from the issue you raised and now I have fully functional comment notifications. Thank you.
Coordinator
Feb 19, 2009 at 10:03 PM
Edited Feb 19, 2009 at 10:05 PM
Great!  I don't think there's anything else that can possibly go wrong with comment notification emails ... at least I hope not!  :)

P.S.  Please don't forget to vote ... :)
Feb 20, 2009 at 12:41 AM
I just used the new code you provided and voila, everything works the way it should and not getting duplicate emails or wrong email in the To field and everyone gets notified if they had chosen to. Now I'm wondering how a commenter can choose not to receive any more notifications, like provide a link in the email to stop receiving the notifications. But I'm asking for too much, you've done an amazing job and I am fully satisfied unless a commenter start complaining LOL. Thank you again.
Coordinator
Feb 21, 2009 at 1:25 AM
rpsitehp: Actually it looks like there is an obscure way to unsubscribe from comment notifications.  If the person who previously subscribed to comment notification for a post, leaves another comment for the same post and doesn't check the "Notify me when new comments are added" box, then when their comment is added, BE also unsubscribes them from comment notifications for the post.

But, it looks like adding a more obvious unsubscribe method is pretty trivial.  Adding an unsubcribe link to the comment notifications like you suggested makes this work pretty smoothly.  I created something to do this.  If you're interested in this, there's 2 things to do.

1. Create two new files in the root of your blog.  The file names are:
    (a) unsubscribe_comment_notification.aspx
    (b) unsubscribe_comment_notification.aspx.cs
    
   The content for these files is down lower in this message.
   
2. Modify that same code we inserted before into the CommentView.ascx.cs file in the User controls folder.  Here's the new version of the same code from yesterday.

if (!isPreview)
{
    Post.AddComment(comment);

    if (comment.IsApproved && Post.NotificationEmails.Count > 0)
    {
        foreach (string recipient in Post.NotificationEmails)
        {
            if (recipient != comment.Email)
            {
                System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();

                mail.From = new System.Net.Mail.MailAddress(BlogSettings.Instance.Email, BlogSettings.Instance.Name);
                mail.Subject = "New comment on " + Post.Title;
                mail.Body = "Comment by " + comment.Author + "<br /><br />";
                mail.Body += comment.Content.Replace(Environment.NewLine, "<br />") + "<br /><br />";
                mail.Body += string.Format("<a href=\"{0}\">{1}</a>", Post.PermaLink + "#id_" + comment.Id, Post.Title);
                mail.Body += "<br /><br />";
                mail.Body += "Unsubscribe from comment notifications to this blog post ";
                mail.Body +=
                    string.Format("<a href=\"{0}unsubscribe_comment_notification.aspx?id={1}&email={2}\">here</a>.",
                    BlogEngine.Core.Utils.AbsoluteWebRoot.ToString(), Post.Id.ToString(), recipient);

                mail.To.Add(recipient);
                Utils.SendMailMessageAsync(mail);
            }
        }
    }

    SetCookie(author, email, website, country);
}


......  here's the content for unsubscribe_comment_notification.aspx ......

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="unsubscribe_comment_notification.aspx.cs" Inherits="unsubscribe_comment_notification" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cphBody" Runat="Server">
  <div style="margin:36px auto;text-align:left;">
    
    <asp:PlaceHolder ID="phSuccessful" runat="server" Visible="false">
        <h1>You have unsubscribed from comment notification</h1>
       
        <b>Blog Post:</b> <asp:Literal ID="litPostTitle" runat="server"></asp:Literal><br />
        <b>Email Address:</b> <asp:Literal ID="litEmailAddress" runat="server"></asp:Literal>
    </asp:PlaceHolder>
    
    <asp:PlaceHolder ID="phNotSubscribed" runat="server">
        <h1>You Were Not Subscribed for Comment Notification</h1>
    </asp:PlaceHolder>
    
  </div>  
</asp:Content>


......  here's the content for unsubscribe_comment_notification.aspx.cs ......

#region Using

using System;
using System.Collections;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BlogEngine.Core;
using BlogEngine.Core.Web.Controls;

#endregion

public partial class unsubscribe_comment_notification : BlogBasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string postId = Request.QueryString["id"];
        string email = Request.QueryString["email"];

        if (!string.IsNullOrEmpty(postId) && postId.Length == 36 && !string.IsNullOrEmpty(email))
        {
            Post p = Post.GetPost(new Guid(postId));
            if (p != null && p.NotificationEmails.Contains(email))
            {
                p.NotificationEmails.Remove(email);

                // Temporarily change the "Description" property of the post so the
                // post gets marked as changed.  Otherwise, when p.Save is called below
                // changes won't get persisted to the data store since the Post will
                // think nothing has changed (yes, this is a hack).

                string currentDescription = p.Description;
                p.Description = (p.Description ?? string.Empty) + " ";
                p.Description = currentDescription;

                p.Save();

                litPostTitle.Text = Server.HtmlEncode(p.Title);
                litEmailAddress.Text = Server.HtmlEncode(email);

                phSuccessful.Visible = true;
                phNotSubscribed.Visible = false;
            }
        }
    }
}