Sending Email in an ASP.NET MVC 4 and C# application

Discussion in 'Email' started by Kekely, Jan 16, 2013.

  1. Hi every body. I have the code below to sending email with my application:

    Code:
    using (var client = new SmtpClient("mail.kekely.com")) {
        client.Port = 25 // also I tried with 587;
        client.DeliveryMethod = SmtpDeliveryMethod.Network;
        client.EnableSsl = false;
        client.UseDefaultCredentials = false;
        client.Credentials = 
            new NetworkCredential("[email protected], "mypassword");
    
        try {
            client.Send(My_Message_Goes_Here);
        } catch (ArgumentNullException) {
            throw;
        } catch (ObjectDisposedException) {
            throw;
        } catch (InvalidOperationException) {
            throw;
        } catch (SmtpFailedRecipientsException) {
            throw;
        } catch (SmtpException) {
            // I get an SmtpException error
            throw;
        } catch (Exception) {
            throw;
        }
    }
    In my local computer it works with port = 587. But when I upload the app to the Winhost it does not work and I get a SmtpException error. I searched the forum and follow any suggestion I found about issues same as mine, but the problem still exists. Do you have any idea please?
     
    Last edited by a moderator: Oct 14, 2015
  2. Elshadriel

    Elshadriel Winhost Staff

    The name servers (DNS) are not pointing to us. You can use m06.internetmailserver.net as your SMTP host if you just want to send through our mail servers but have your mail hosted somewhere else, or you can update your DNS records.
     
  3. No my have not a mail server somewhere else.
    I have registered my domain on GoDaddy, but I don't know how to set my DNS records to Winhost specifics. Actually Winhost does not supplied full information about DNS records. I just set my @ records to access my host on Winhost.
     
  4. Elshadriel

    Elshadriel Winhost Staff

    Last edited by a moderator: Oct 14, 2015

Share This Page