Still have an issue with sending email!

Discussion in 'Email' started by Paul, Nov 26, 2011.

  1. Hi Guys

    I've read all of the posts about issues with sending emails from an ASP.NET WebForm, and have tested all the solutions! Nothing works! Can anyone give me a clue what's the problem?

    Here's what I have in codebehind:
    Code:
    try
                    {
                        MailMessage mailMessage = new MailMessage()
                        {
                            From = new MailAddress("support@myDomainName.com"),
                            Subject = "Some Message",
                            BodyEncoding = Encoding.UTF8,
                            Body = "Some texts",
                            IsBodyHtml = true
                        };
                        mailMessage.To.Add(new MailAddress("support@myDomainName.com"));
    
                        SmtpClient smtp = new SmtpClient();                   
                        smtp.EnableSsl = true;
                        smtp.Send(mailMessage);
                    }
                    catch { }
    
    And Web.config is like below:

    HTML:
    <system.net>
            <mailSettings>
                <smtp>
                    <network host="mail.myDomainName.net" port="25" userName="support@myDomainName.com" password="myPassowrd" />
                </smtp>
            </mailSettings>
        </system.net>
    
    I'm just curious about DNS issues. I don't know much about them. I don't have any CNAME Records or TXT Records. Just have an MX Record like this:

    Domain Name Mail Server Priority TTL
    myDomainName.com *.internetmailserver.net 10 3600

    Thanks for your help.
     
  2. What's your domain name?
     
  3. myperfectdays.com

    Another thing: When I changed this
    Code:
    smtp.EnableSsl = false;
    Everything works fine in my local host, BUT still doesn't work on Winhost!

    Update: Now Works fine! So, the issue was

    Code:
    smtp.EnableSsl = false;
    After that I hit refresh page and it works fine on Winhost!
     
    Last edited by a moderator: Oct 14, 2015
  4. I'm really confused! Now it works for some pages and does not work form some others!!!
     
  5. Last edited by a moderator: Mar 20, 2017
  6. Yes, actually one of those pages works fine (after I changed EnableSsl to false) but others still have problem. I can't understand.

    It causes an exception that told "Can not connect to remote host" or sth like that.
     
  7. Ray

    Ray

    Whats the full and exact error message? From the symptoms you are describing, I suspect you do not have the smtp server pointing to the correct mail server.
     
  8. SmptException was caught. Failure sending mail. (System.Net.Mail.SmtpException)

    InnerException: Unable to connect to the remote server.
     
  9. Ray

    Ray

    Definitely sounds like you do not have the correct smtp server typed in your code. If you have one part of your application sending out emails through our email server, but others can't, than the root cause can be the smtp server being pointed to. It maybe misspelled.
     
  10. I change my code to this. And still have problem with ALL pages.

    Code:
    try
    {
         MailMessage mailMessage = new MailMessage()
         {
             From = new MailAddress("support@myperfectdays.com"),
             Subject = "Message from contact page",
             BodyEncoding = Encoding.UTF8,
             Body = parser.Parse(),
             IsBodyHtml = true
         };
         mailMessage.To.Add(new MailAddress("******@gmail.com"));
         SmtpClient smtp = new SmtpClient("mail.myperfectdays.com", 587);                   
         smtp.EnableSsl = false;
         smtp.Credentials = new System.Net.NetworkCredential("support@myperfectdays.com", "*******");
         smtp.UseDefaultCredentials = false;
         smtp.Send(mailMessage);
    }
    catch { }
    
    But now exception is this:

    Code:
    Mailbox unavailable. The server response was: <*******@gmail.com> No such user here
    
    Why the server looks for that gmail address in its users list?! That's a TO address, not FROM address.
     
  11. Elshadriel

    Elshadriel Winhost Staff

    Try authenticating with the postmaster account instead.
     
  12. I'm sorry, but how should I know password of postmaster account? I always use that link from Email section of control panel.
     
  13. Try the same password you use to get in to Control Panel. That's the postmaster default password.
     
  14. No, It's not. because I can't sign in to postmaster using that password. I tried to change the postmaster password, but it needs current password. Seems I'm in a loop. Is there any option to reset the postmaster completely to its default status?

    BTW, I noticed there's no record in
    Mail Settings > Advanced Settings > SMTP Accounts
    of the postmaster. Could it be a problem?
     
  15. OK. Problem Solved. someone else had changed that pass. After using postmaster account all thing goes well. So to tell anybody who read this thread and has the same problem I could say:

    1- Don't use SSL for email (smtp.EnableSsl = false)
    2- use postmaster account for SMTP Authentication. Then you could use anyone your email accounts (support, info, etc.) to send email to users.
    3- SMTP Authentication could be in web.config or in codebehind. Both of them works.

    Thanks to all technical staffs of Winhost.
     
    Last edited by a moderator: Oct 14, 2015
  16. email

    I too am having the same problem except I do not use the ssl at all. I have used every idea in these threads and still nothing works. Worked fine went I test locally but as soon as I put up in Winhost it quit working. Here is my code

    MailMessage myMessage = new MailMessage();
    myMessage.From = new MailAddress(sendEmail, sendName);
    myMessage.To.Add(new MailAddress("contact@mydomain.com"));
    myMessage.Subject = "Customer Contact";
    myMessage.Body = mailBody;
    myMessage.IsBodyHtml = true;

    SmtpClient mySmtpClient = new SmtpClient();
    NetworkCredential AuthenticationInfo = new NetworkCredential("postmaster@mydomain.com", "password");
    mySmtpClient.Host = "mail.mydomain.com";
    mySmtpClient.Port = 587; // 25
    mySmtpClient.UseDefaultCredentials = false;
    mySmtpClient.Credentials = AuthenticationInfo;

    mySmtpClient.Send(myMessage);
     
  17. Here's what I did to fix my SMTP issues...

    For those (like me) who need pretty pictures, here are screenshots on how I configured SMTP settings to solve my "Mail Undeliverable" etc. problem. 1st image is the IIS SMTP settings, 2nd image is the web.config settings. Replace the blacked-out domain name (to protect the guilty, in my case) with your own domain name. HTH
     

    Attached Files:

  18. Nice work.
     

Share This Page