Cannot send Email from server

Discussion in 'Email' started by Henry, Mar 25, 2011.

  1. I just joined Winhost and try to run a C# program for the online registration. This program was running well from another hosting company but does not run here. I don't have the domain pointing to this server, which was not required from the previous hosting company. It would be great if you can help. Please find the following code, thanks:

    MailMessage mailMsg = new MailMessage();
    //mailMsg.To.Add("[email protected]");
    mailMsg.To.Add("[email protected]");
    string Name = tbFirstName.Text + " " + tbLastName.Text;

    // From
    MailAddress from = new MailAddress(tbEmail.Text, Name);
    mailMsg.From = from;

    // Subject
    mailMsg.Subject = "eBook";

    // Body
    mailMsg.IsBodyHtml = true;

    // - Profile
    string body = "<br>Email:" + " <font color=blue>" + tbEmail.Text + "</font>";
    body = body + "<br>First Name:" + " <font color=blue>" + tbFirstName.Text + "</font>";
    body = body + "<br>Last Name:" + " <font color=blue>" + tbLastName.Text + "</font>";
    body = body + "<br>Job Title:" + " <font color=blue>" + tbJobTitle.Text + "</font>";
    body = body + "<br>Company:" + " <font color=blue>" + tbCompany.Text + "</font>";
    body = body + "<br>Country:" + " <font color=blue>" + ddlCountry.SelectedItem.Text + "</font>";

    body = body + "<br><br><hr>";

    // - Comments
    body = body + "<plaintext>" + tbComments.Text;
    mailMsg.Body = body;

    // Init SmtpClient and send
    SmtpClient smtpClient = new SmtpClient("Localhost", 25);
    smtpClient.Credentials = CredentialCache.DefaultNetworkCredentials;
    smtpClient.Send(mailMsg);
     
    Last edited by a moderator: Oct 14, 2015
  2. Ray

    Ray

    We do not use "Localhost" at Winhost to relay out email. We have disabled the SMTP service on our web server. Rather you will need to use the email server provided with your hosting account. Try looking at this kb article for an example code. Furthermore, our SMTP server requires SMTP authentication, so make sure you pass the login credentials to your SMTP server. It should be the full email address of the POP account and the password associated to it.

    http://support.Winhost.com/KB/a650/how-to-send-email-in-aspnet.aspx
     
    Last edited by a moderator: Oct 14, 2015

Share This Page