Some get error failure sending mail ( System.Net.Mail)

Discussion in 'ASP .Net' started by satnamsarai@gmail.com, Sep 21, 2007.

  1. Guest

    Using System.Net.Mail: Sometimes I get error 'failure sending mail.
    Unable to write data to the transport connection: An existing
    connection was forcibly closed by the remote host.' Not sure how to
    fix this error.

    I am able to send messages sometimes both other times randomly
    following error appear


    EXCEPTION:
    Exception of type 'System.Web.HttpUnhandledException' was thrown.
    at System.Web.UI.Page.HandleError(Exception e)
    at System.Web.UI.Page.ProcessRequestMain(Boolean
    includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    at System.Web.UI.Page.ProcessRequest(Boolean
    includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    at System.Web.UI.Page.ProcessRequest()
    at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext
    context)
    at System.Web.UI.Page.ProcessRequest(HttpContext context)
    at ASP.coursecert_presenter_main_aspx.ProcessRequest(HttpContext
    context)
    at
    System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
    at System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
    Boolean& completedSynchronously)
    INNER EXCEPTION:
    Failure sending mail.
    at System.Net.Mail.SmtpClient.Send(MailMessage message)
    at coursecert.utility.SendEmail(Object from_email, Object
    from_name, Object to_email, Object email_subject, Object
    email_message)
    at coursecert.utility.SendAMail(String email_subject, String
    email_message, Int32 cert_tracking_id, String email_to)
    at ASP.coursecert_presenter_main_aspx.SendMail(Int32 message_ind)
    at
    ASP.coursecert_presenter_main_aspx.btnSendtoPRODUCTION_click(Object
    sender, EventArgs e)
    at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
    at System.Web.UI.WebControls.Button.RaisePostBackEvent(String
    eventArgument)
    at
    System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
    eventArgument)
    at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
    sourceControl, String eventArgument)
    at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection
    postData)
    at System.Web.UI.Page.ProcessRequestMain(Boolean
    includeStagesBeforeAsyncPoint, Boolean
    includeStagesAfterAsyncPoint)
    INNER EXCEPTION:
    Unable to write data to the transport connection: An existing
    connection was forcibly closed by the remote host.
    at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32
    offset, Int32 size)
    at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32
    size)
    at System.Net.Mail.SmtpConnection.Flush()
    at System.Net.Mail.CheckCommand.Send(SmtpConnection conn, String&
    response)
    at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[]
    command, String from)
    at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender,
    MailAddressCollection recipients, String deliveryNotify,
    SmtpFailedRecipientException& exception)
    at System.Net.Mail.SmtpClient.Send(MailMessage message)
    INNER EXCEPTION:
    An existing connection was forcibly closed by the remote host
    at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset,
    Int32 size, SocketFlags socketFlags)
    at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32
    offset, Int32 size)
    , Sep 21, 2007
    #1
    1. Advertising

  2. >> An existing connection was forcibly closed by the remote host

    Without seeing any code, the first thing that comes to mind (and has caught
    me on a few projects) has been various anti-virus softwares blocking port
    25 or the SMTP server you're using hasn't been provided with the correct
    authentication information.

    If you can, post up your code.

    -dl

    --
    David R. Longnecker
    http://blog.tiredstudent.com

    > Using System.Net.Mail: Sometimes I get error 'failure sending mail.
    > Unable to write data to the transport connection: An existing
    > connection was forcibly closed by the remote host.' Not sure how to
    > fix this error.
    >
    > I am able to send messages sometimes both other times randomly
    > following error appear
    >
    > EXCEPTION:
    > Exception of type 'System.Web.HttpUnhandledException' was thrown.
    > at System.Web.UI.Page.HandleError(Exception e)
    > at System.Web.UI.Page.ProcessRequestMain(Boolean
    > includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    > at System.Web.UI.Page.ProcessRequest(Boolean
    > includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    > at System.Web.UI.Page.ProcessRequest()
    > at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext
    > context)
    > at System.Web.UI.Page.ProcessRequest(HttpContext context)
    > at ASP.coursecert_presenter_main_aspx.ProcessRequest(HttpContext
    > context)
    > at
    > System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApp
    > lication.IExecutionStep.Execute()
    > at System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
    > Boolean& completedSynchronously)
    > INNER EXCEPTION:
    > Failure sending mail.
    > at System.Net.Mail.SmtpClient.Send(MailMessage message)
    > at coursecert.utility.SendEmail(Object from_email, Object
    > from_name, Object to_email, Object email_subject, Object
    > email_message)
    > at coursecert.utility.SendAMail(String email_subject, String
    > email_message, Int32 cert_tracking_id, String email_to)
    > at ASP.coursecert_presenter_main_aspx.SendMail(Int32 message_ind)
    > at
    > ASP.coursecert_presenter_main_aspx.btnSendtoPRODUCTION_click(Object
    > sender, EventArgs e)
    > at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
    > at System.Web.UI.WebControls.Button.RaisePostBackEvent(String
    > eventArgument)
    > at
    > System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.R
    > aisePostBackEvent(String
    > eventArgument)
    > at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
    > sourceControl, String eventArgument)
    > at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection
    > postData)
    > at System.Web.UI.Page.ProcessRequestMain(Boolean
    > includeStagesBeforeAsyncPoint, Boolean
    > includeStagesAfterAsyncPoint)
    > INNER EXCEPTION:
    > Unable to write data to the transport connection: An existing
    > connection was forcibly closed by the remote host.
    > at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32
    > offset, Int32 size)
    > at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32
    > size)
    > at System.Net.Mail.SmtpConnection.Flush()
    > at System.Net.Mail.CheckCommand.Send(SmtpConnection conn, String&
    > response)
    > at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[]
    > command, String from)
    > at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender,
    > MailAddressCollection recipients, String deliveryNotify,
    > SmtpFailedRecipientException& exception)
    > at System.Net.Mail.SmtpClient.Send(MailMessage message)
    > INNER EXCEPTION:
    > An existing connection was forcibly closed by the remote host
    > at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset,
    > Int32 size, SocketFlags socketFlags)
    > at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32
    > offset, Int32 size)
    David R. Longnecker, Sep 21, 2007
    #2
    1. Advertising

  3. Guest

    On Sep 21, 11:24 am, David R. Longnecker
    <> wrote:
    > >> An existing connection was forcibly closed by the remote host

    >
    > Without seeing any code, the first thing that comes to mind (and has caught
    > me on a few projects) has been various anti-virus softwares blocking port
    > 25 or the SMTP server you're using hasn't been provided with the correct
    > authentication information.
    >
    > If you can, post up your code.
    >
    > -dl
    >
    > --
    > David R. Longneckerhttp://blog.tiredstudent.com
    >
    >
    >
    > > Using System.Net.Mail: Sometimes I get error 'failure sending mail.
    > > Unable to write data to the transport connection: An existing
    > > connection was forcibly closed by the remote host.' Not sure how to
    > > fix this error.

    >
    > > I am able to send messages sometimes both other times randomly
    > > following error appear

    >
    > > EXCEPTION:
    > > Exception of type 'System.Web.HttpUnhandledException' was thrown.
    > > at System.Web.UI.Page.HandleError(Exception e)
    > > at System.Web.UI.Page.ProcessRequestMain(Boolean
    > > includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    > > at System.Web.UI.Page.ProcessRequest(Boolean
    > > includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    > > at System.Web.UI.Page.ProcessRequest()
    > > at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext
    > > context)
    > > at System.Web.UI.Page.ProcessRequest(HttpContext context)
    > > at ASP.coursecert_presenter_main_aspx.ProcessRequest(HttpContext
    > > context)
    > > at
    > > System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApp
    > > lication.IExecutionStep.Execute()
    > > at System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
    > > Boolean& completedSynchronously)
    > > INNER EXCEPTION:
    > > Failure sending mail.
    > > at System.Net.Mail.SmtpClient.Send(MailMessage message)
    > > at coursecert.utility.SendEmail(Object from_email, Object
    > > from_name, Object to_email, Object email_subject, Object
    > > email_message)
    > > at coursecert.utility.SendAMail(String email_subject, String
    > > email_message, Int32 cert_tracking_id, String email_to)
    > > at ASP.coursecert_presenter_main_aspx.SendMail(Int32 message_ind)
    > > at
    > > ASP.coursecert_presenter_main_aspx.btnSendtoPRODUCTION_click(Object
    > > sender, EventArgs e)
    > > at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
    > > at System.Web.UI.WebControls.Button.RaisePostBackEvent(String
    > > eventArgument)
    > > at
    > > System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.R
    > > aisePostBackEvent(String
    > > eventArgument)
    > > at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
    > > sourceControl, String eventArgument)
    > > at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection
    > > postData)
    > > at System.Web.UI.Page.ProcessRequestMain(Boolean
    > > includeStagesBeforeAsyncPoint, Boolean
    > > includeStagesAfterAsyncPoint)
    > > INNER EXCEPTION:
    > > Unable to write data to the transport connection: An existing
    > > connection was forcibly closed by the remote host.
    > > at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32
    > > offset, Int32 size)
    > > at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32
    > > size)
    > > at System.Net.Mail.SmtpConnection.Flush()
    > > at System.Net.Mail.CheckCommand.Send(SmtpConnection conn, String&
    > > response)
    > > at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[]
    > > command, String from)
    > > at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender,
    > > MailAddressCollection recipients, String deliveryNotify,
    > > SmtpFailedRecipientException& exception)
    > > at System.Net.Mail.SmtpClient.Send(MailMessage message)
    > > INNER EXCEPTION:
    > > An existing connection was forcibly closed by the remote host
    > > at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset,
    > > Int32 size, SocketFlags socketFlags)
    > > at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32
    > > offset, Int32 size)- Hide quoted text -

    >
    > - Show quoted text -



    Here is the code.. It work fine sometimes, but when this function is
    called repealy, then it break down!..


    Sub sendAmail()
    Dim send_mail_ip As String =
    System.Configuration.ConfigurationManager.AppSettings("send_mail_ip")
    Dim mail As New MailMessage()

    If Trim(txtToEmail.Text) <> String.Empty And
    Trim(send_mail_ip) <> String.Empty Then
    Dim smtp As New SmtpClient(Trim(send_mail_ip))
    mail.From = New MailAddress(Trim(txtFromEmail.Text),
    Trim(txtFromEmail.Text))
    mail.To.Add(Trim(txtToEmail.Text))
    mail.Subject = txtSubject.Text
    mail.Body = txtMessage.Text

    smtp.Send(mail)

    lblAlert.Text = "<font color =""green"">Email Send</font>"
    End If

    End Sub
    , Sep 21, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    4
    Views:
    55,439
  2. Replies:
    0
    Views:
    1,334
  3. JoeP
    Replies:
    10
    Views:
    855
  4. Don Quijote de Nicaragua

    Error + Send Mail + ERROR: Failure sending mail.

    Don Quijote de Nicaragua, Jun 26, 2008, in forum: ASP .Net
    Replies:
    5
    Views:
    1,506
    Don Quijote de Nicaragua
    Jun 26, 2008
  5. Ben Gribaudo
    Replies:
    6
    Views:
    190
    Ben Gribaudo
    Apr 19, 2005
Loading...

Share This Page