SMTP mailSent/serverError handlers not working

  1. 6 days ago

    James M

    Nov 8 South Devon England

    Hi all...I have a web service which sends email via my own mail server.
    The app sends the email but always returns http status code 500.

    In HandleSpecialURL

    Select case Request.Path
        case "EMAIL"
          if sendEmail then
          Request.Status = emailSentStatus
          Return True
        end if

    I have mapped the smtp secure sockets 'mail sent handler' and 'mail server error handler' on the open event of the App:
    AddHandler MailSocket.MailSent, AddressOf MailSentHandler AddHandler MailSocket.ServerError, AddressOf MailServerErrorHandler

    I have created the necessary methods

    Sub MailSentHandler(m as SMTPSecureSocket)
    
      emailSentStatus = 200
      mailSemaphore.Release // Release the Semaphore to make the socket available for use
      End Sub
    Sub MailServerErrorHandler(m as SMTPSecureSocket, errorID as Integer, errorMessage as string, email as EmailMessage)
      emailSentStatus = errorID
      errorTXT = errorMessage
      mailSemaphore.Release // Release the Semaphore to make the socket available for use
    End Sub

    I'm guessing that the default status code is being returned due to 200 not being created by the message sent handler.

    Any thoughts ??

or Sign Up to reply!