Looking for best method error handling bad emails (system.web.mail)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Max

    Looking for best method error handling bad emails (system.web.mail)

    Sometimes I get this error when testing web.mail:
    The server rejected one or more recipient addresses
    The server response was: 473 kjhg@Kjhg.com relaying prohibited. You should
    authenticate first

    This goes away when I simply put a try/catch around sending email, but I'm
    wondering if I can use this to my advantage -- come back to the user saying
    their email is invalid, try again?

    I'm asking if this is a good method, since I'm a little bit hesitant to form
    my business logic around a try/catch -- I'm under the impression try/catch
    is to be used for error handling only.

    -Max


  • Kevin Spencer

    #2
    Re: Looking for best method error handling bad emails (system.web.mai l)

    The error message indicates that relaying is prohibited. It says nothing
    about the user's email address being valid.

    Putting a try-catch around it only ignores the error. In other words, no
    email is sent; you just don't find out about it.

    --
    HTH,
    Kevin Spencer
    ..Net Developer
    Microsoft MVP
    Big things are made up
    of lots of little things.

    "Max" <maximus@portvi sta.com> wrote in message
    news:ZxIqc.6347 72$Po1.593244@t wister.tampabay .rr.com...[color=blue]
    > Sometimes I get this error when testing web.mail:
    > The server rejected one or more recipient addresses
    > The server response was: 473 kjhg@Kjhg.com relaying prohibited. You should
    > authenticate first
    >
    > This goes away when I simply put a try/catch around sending email, but I'm
    > wondering if I can use this to my advantage -- come back to the user[/color]
    saying[color=blue]
    > their email is invalid, try again?
    >
    > I'm asking if this is a good method, since I'm a little bit hesitant to[/color]
    form[color=blue]
    > my business logic around a try/catch -- I'm under the impression try/catch
    > is to be used for error handling only.
    >
    > -Max
    >
    >[/color]


    Comment

    • Max

      #3
      Re: Looking for best method error handling bad emails (system.web.mai l)

      I always get that error when it's an email that doesn't exist. Don't ask me
      how it knows... but when I use an email address I know works, it sends just
      fine. Maybe it's just an error coming from the SMTP server, in which case
      the error would be different depending on the SMTP server it's using...

      But you didn't address the question -- I could use try/catch not just to
      ignore it, but to return the user back to the form and ask the user to enter
      a valid email address. But my concern is that I'm now using try/catch for
      actual business logic, not just friendly error message handling.

      -Max

      "Kevin Spencer" <kspencer@takem pis.com> wrote in message
      news:eZpUs6ZPEH A.1644@TK2MSFTN GP09.phx.gbl...[color=blue]
      > The error message indicates that relaying is prohibited. It says nothing
      > about the user's email address being valid.
      >
      > Putting a try-catch around it only ignores the error. In other words, no
      > email is sent; you just don't find out about it.
      >
      > --
      > HTH,
      > Kevin Spencer
      > .Net Developer
      > Microsoft MVP
      > Big things are made up
      > of lots of little things.
      >
      > "Max" <maximus@portvi sta.com> wrote in message
      > news:ZxIqc.6347 72$Po1.593244@t wister.tampabay .rr.com...[color=green]
      > > Sometimes I get this error when testing web.mail:
      > > The server rejected one or more recipient addresses
      > > The server response was: 473 kjhg@Kjhg.com relaying prohibited. You[/color][/color]
      should[color=blue][color=green]
      > > authenticate first
      > >
      > > This goes away when I simply put a try/catch around sending email, but[/color][/color]
      I'm[color=blue][color=green]
      > > wondering if I can use this to my advantage -- come back to the user[/color]
      > saying[color=green]
      > > their email is invalid, try again?
      > >
      > > I'm asking if this is a good method, since I'm a little bit hesitant to[/color]
      > form[color=green]
      > > my business logic around a try/catch -- I'm under the impression[/color][/color]
      try/catch[color=blue][color=green]
      > > is to be used for error handling only.
      > >
      > > -Max
      > >
      > >[/color]
      >
      >
      >[/color]


      Comment

      Working...