Problem sending mails

Discussion in 'ASP.NET 2.0' started by Shaqur, Sep 21, 2007.

  1. [​IMG]I am trying to send emails from my web application but it doesnt seem to work. I need to send emails containing users details uponregistering with the site, emails to users who forget their passwords and requests for them, i also need to send newsletters to users who have subscribed for the service. An attempt to do any of the above results into the following error.


    The remote name could not be resolved: '(localhost)' Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Net.WebException: The remote name could not be resolved: '(localhost)'

    Source Error:





    Code:
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
    Stack Trace:





    Code:
    [WebException: The remote name could not be resolved: '(localhost)']
       System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout) +1475352
       System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) +190
       System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) +21
       System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) +318
       System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) +227
       System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) +316
       System.Net.Mail.SmtpClient.GetConnection() +42
       System.Net.Mail.SmtpClient.Send(MailMessage message) +1485
    
    [SmtpException: Failure sending mail.]
       System.Net.Mail.SmtpClient.Send(MailMessage message) +2074
       System.Web.UI.WebControls.LoginUtil.SendPasswordMail(String email, String userName, String password, MailDefinition mailDefinition, String defaultSubject, String defaultBody, OnSendingMailDelegate onSendingMailDelegate, OnSendMailErrorDelegate onSendMailErrorDelegate, Control owner) +341
       System.Web.UI.WebControls.CreateUserWizard.AttemptCreateUser() +571
       System.Web.UI.WebControls.CreateUserWizard.OnNextButtonClick(WizardNavigationEventArgs e) +105
       System.Web.UI.WebControls.Wizard.OnBubbleEvent(Object source, EventArgs e) +453
       System.Web.UI.WebControls.CreateUserWizard.OnBubbleEvent(Object source, EventArgs e) +149
       System.Web.UI.WebControls.WizardChildTable.OnBubbleEvent(Object source, EventArgs args) +17
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
       System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +115
       System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +163
       System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
    




    I am using the framework's <MailDefinition /> inmy forms as follows


    <MailDefinition


    BodyFileName="~/somemail.txt"


    From=[email protected]


    Subject="Some subject">


    </MailDefinition>


    Then in my web. config file i have the following in my <mailsettings> section


    <system.net>


    <mailSettings>


    <smtp deliveryMethod="Network" from="someaddress">


    <network defaultCredentials="true" host="(localhost)" port="25"/>


    </smtp>


    </mailSettings>


    </system.net>


    I am worndering if there is something i am not doing right!.
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    are you running this off our server? the error doesn't make any sense.

    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  3. Why are you specifying host='(localhost)'? Just have host='localhost' instead!

    Vikram

    DiscountASP.NET
    www.DiscountASP.NET
     

Share This Page