locked
Unable to send email using bulehost? RRS feed

  • Question

  • User-353733005 posted

    I created a page where I can send email from my email address. I am using bluehost email hosting service. But the problem is I am unable to send email using bluehost server. But in gmail, live, yahoo all mail are sending only bluehost can't send any email. Can anyone help me please.

    Here is my code:

    public void SendMail()
            {
                try
                {
                    string ActivationUrl = String.Empty;                
    
                    ActivationUrl = "http://localhost:XXXXX/ActivateAccount.aspx?UserID=";
                    
                    MailMessage msg = new MailMessage();
                    msg.From = new MailAddress("email@domain.com");                
                    msg.To.Add("toEmail@gmail.com");                
                    msg.Subject = "Confirmation email for activation the account";                
                    msg.Body = "Please <a href='" + ActivationUrl + "'>click here to activate</a>  your account and enjoy our services.";
                    msg.IsBodyHtml = true;
    
                    SmtpClient smtpServer = new SmtpClient(); 
                    smtpServer.Credentials = new NetworkCredential("email@domain.com", "*****");
                    smtpServer.Port = 26;
                    smtpServer.Host = "mail.myhost.com";
                    smtpServer.EnableSsl = true;
                    smtpServer.Timeout = 1000;
                    smtpServer.Send(msg);
                    Success = true;
                }
                catch (Exception ex)
                {
                    Success = false;
                    ErrorMessage = ex.Message;
                }
            }

    Sunday, April 5, 2015 11:36 AM

Answers