error sending mail - remote name could not be resolved

Discussion in 'Email' started by segiles, Jun 27, 2010.

  1. I get an error sending email when using your sample c# code.

    http://www.bakushopping.com/webform1.aspx

    Error:
    System.Net.WebException: The remote name could not be resolved: 'mail.bakushopping.com' at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout) at System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpClient.GetConnection() at System.Net.Mail.SmtpClient.Send(MailMessage message)

    ---------------------------------

    <%@ Import Namespace="System.Net.Mail" %>

    <script language="C#" runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
    //create the mail message
    MailMessage mail = new MailMessage();

    //set the addresses
    mail.From = new MailAddress("postmaster@bakushopping.com");
    mail.To.Add("postmaster@bakushopping.com");

    //set the content
    mail.Subject = "This is an email";
    mail.Body = "This is from system.net.mail using C sharp with smtp authentication.";
    //send the message
    SmtpClient smtp = new SmtpClient("mail.bakushopping.com");

    NetworkCredential Credentials = new NetworkCredential("postmaster@bakushopping.com", "******");
    smtp.Credentials = Credentials;

    try
    {
    smtp.Send(mail);
    lblMessage.Text = "Mail Sent";
    }
    catch (Exception ex)
    {
    lblMessage.Text = ex.InnerException.ToString();
    }
    }
    </script>
    <html>
    <body>
    <form id="Form1" runat="server">
    <asp:Label id="lblMessage" runat="server"></asp:Label>
    </form>
    </body>
    </html>
     
  2. fixed

    Found the problem. I updated my DNS entries a few hours ago, and it appears the changes to smpt server is not yet available. I did a nslookup on my smpt server to get the ip, and then changed my mail server name to the IP, and then everything worked fine.
     
  3. Thanks for posting the follow-up.
     

Share This Page