SMTP "Relay Denied" on localhost! (windows server 2003)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Carmine [www.thetotalsite.it]

    SMTP "Relay Denied" on localhost! (windows server 2003)

    Hi everyone,
    I get a really odd error while using SMTPClient.Send () function in ASP.Net.
    The error is the following:

    Dim smtp As New Net.Mail.SmtpCl ient("smtp.thet otalsite.it", 25)
    Dim bodyMSG As String
    bodyMSG = "something"
    smtp.Send("some thing@thetotals ite.it",
    someone@gmail.c om, "Message from thetotalsite", bodyMSG)

    Well, on my local machine (using the integrated web server of Visual
    Studio), it works...
    Incredibly, on the remote web server, it does not work!
    It seems as if the web server filtered emails coming from localhost/ASP.Net
    runtime o.O
    The runtime give me this error:

    System.Net.Mail .SmtpFailedReci pientException: Mailbox unavailable. The
    server response was: Relay denied
    at System.Net.Mail .SmtpTransport. SendMail(MailAd dress sender,
    MailAddressColl ection recipients, String deliveryNotify,
    SmtpFailedRecip ientException& exception)
    at System.Net.Mail .SmtpClient.Sen d(MailMessage message)
    at System.Net.Mail .SmtpClient.Sen d(String from, String recipients, String
    subject, String body)
    at controls_commen ts.Submit_Click (Object sender, EventArgs e)

    So, "Relay denied"... But I'm using an existing email account!
    (something@thet otalsite.it) and, in fact, it works perfectly on Outlook
    Express or Visual Studio.
    Why this strange behavior? Is it a bug? How can I solve it?

    Thanks in advance,

    P.s.: I'm using .Net Framework 2.0.

    --
    Carmine
    Webmaster di www.thetotalsite.it
    Blog http://blog.thetotalsite.it

  • Carmine [www.thetotalsite.it]

    #2
    Re: SMTP "Relay Denied" on localhost! (windows server 2003)

    Besides, curiously the SMTP server works perfectly on the remote web server
    if I send the email TO an address that has the domain "thetotalsite.i t" and
    in the FROM field the same email address (with the domain
    "thetotalsite.i t")...
    However, in Visual Studio and in Outlook Express, the smtp server works
    perfectly even if I send the email to an address that has any domain (gmail,
    hotmail, etc.).

    Bye,

    --
    Carmine
    Webmaster di www.thetotalsite.it
    Blog http://blog.thetotalsite.it

    Comment

    • Norman Yuan

      #3
      Re: SMTP "Relay Denied" on localhost! (windows server 2003)

      How is the ASP.NET app/website configured? That is, which user account is
      used to run it? When you test your app with VS built-in web server, the
      ASP.NET app and/or web server worker process may well run under your user
      account (domain, or local, possibly an admin?), which has needed permission.

      You need to know which account is used to run your ASP.NET on that web
      server box (as developer, you should know it, shouldn't you?) and then
      examine the SMTP server in that box to see its access/relay settings.

      "Carmine [www.thetotalsit e.it]" <pikachu31@gmai l.comwrote in message
      news:2E7FDA1C-A333-4C50-94AD-6AC2FFAA7B59@mi crosoft.com...
      Hi everyone,
      I get a really odd error while using SMTPClient.Send () function in
      ASP.Net.
      The error is the following:
      >
      Dim smtp As New Net.Mail.SmtpCl ient("smtp.thet otalsite.it", 25)
      Dim bodyMSG As String
      bodyMSG = "something"
      smtp.Send("some thing@thetotals ite.it",
      someone@gmail.c om, "Message from thetotalsite", bodyMSG)
      >
      Well, on my local machine (using the integrated web server of Visual
      Studio), it works...
      Incredibly, on the remote web server, it does not work!
      It seems as if the web server filtered emails coming from
      localhost/ASP.Net runtime o.O
      The runtime give me this error:
      >
      System.Net.Mail .SmtpFailedReci pientException: Mailbox unavailable. The
      server response was: Relay denied
      at System.Net.Mail .SmtpTransport. SendMail(MailAd dress sender,
      MailAddressColl ection recipients, String deliveryNotify,
      SmtpFailedRecip ientException& exception)
      at System.Net.Mail .SmtpClient.Sen d(MailMessage message)
      at System.Net.Mail .SmtpClient.Sen d(String from, String recipients,
      String
      subject, String body)
      at controls_commen ts.Submit_Click (Object sender, EventArgs e)
      >
      So, "Relay denied"... But I'm using an existing email account!
      (something@thet otalsite.it) and, in fact, it works perfectly on Outlook
      Express or Visual Studio.
      Why this strange behavior? Is it a bug? How can I solve it?
      >
      Thanks in advance,
      >
      P.s.: I'm using .Net Framework 2.0.
      >
      --
      Carmine
      Webmaster di www.thetotalsite.it
      Blog http://blog.thetotalsite.it

      Comment

      • Carmine [www.thetotalsite.it]

        #4
        Re: SMTP &quot;Relay Denied&quot; on localhost! (windows server 2003)

        How is the ASP.NET app/website configured? That is, which user account is
        used to run it? When you test your app with VS built-in web server, the
        ASP.NET app and/or web server worker process may well run under your user
        account (domain, or local, possibly an admin?), which has needed
        permission.
        On my local machine I use my standard account.
        On the web server I don't know, because the web server is not mine (I'm on a
        shared hosting service); but I think it is the normal "ASP.Net" account.

        The odd thing is that the smtp server works on every computer except the
        same web server on which the smtp server is running!

        Bye,

        --
        Carmine
        Webmaster di www.thetotalsite.it
        Blog http://blog.thetotalsite.it

        Comment

        • sloan

          #5
          Re: SMTP &quot;Relay Denied&quot; on localhost! (windows server 2003)


          Try this homemade library:
          http://sholliday.space s.live.com/Blog/cns!A68482B9628 A842A!138.entry

          AND

          Some notes I found in my commented code:
          // see http://www.systemwebmail.com/faq/4.2.3.aspx
          // for common issues
          // Make sure you GRANT relay privledges for "127.0.0.1"

          /*
          *
          * Suggestion 2
          If you are using "localhost" or "127.0.0.1" as
          the SmtpMail.SmtpSe rver, you may not have permissions
          to relay through the IIS SMTP Service.
          To allow access, open up the IIS Admin MMC.
          Locate the SMTP Virtual Server, and right-click,
          then select Properties. On the Access tab, click the Relay button.
          In the Relay Restrictions dialog, grant your IP address (127.0.0.1)
          to the Computers listbox. Close down all dialogs,
          and restart the SMTP Service.
          */

          //Also check that the SMTP service is running on your machine.




          "Carmine [www.thetotalsit e.it]" <pikachu31@gmai l.comwrote in message
          news:2E7FDA1C-A333-4C50-94AD-6AC2FFAA7B59@mi crosoft.com...
          Hi everyone,
          I get a really odd error while using SMTPClient.Send () function in
          ASP.Net.
          The error is the following:
          >
          Dim smtp As New Net.Mail.SmtpCl ient("smtp.thet otalsite.it", 25)
          Dim bodyMSG As String
          bodyMSG = "something"
          smtp.Send("some thing@thetotals ite.it",
          someone@gmail.c om, "Message from thetotalsite", bodyMSG)
          >
          Well, on my local machine (using the integrated web server of Visual
          Studio), it works...
          Incredibly, on the remote web server, it does not work!
          It seems as if the web server filtered emails coming from
          localhost/ASP.Net runtime o.O
          The runtime give me this error:
          >
          System.Net.Mail .SmtpFailedReci pientException: Mailbox unavailable. The
          server response was: Relay denied
          at System.Net.Mail .SmtpTransport. SendMail(MailAd dress sender,
          MailAddressColl ection recipients, String deliveryNotify,
          SmtpFailedRecip ientException& exception)
          at System.Net.Mail .SmtpClient.Sen d(MailMessage message)
          at System.Net.Mail .SmtpClient.Sen d(String from, String recipients,
          String
          subject, String body)
          at controls_commen ts.Submit_Click (Object sender, EventArgs e)
          >
          So, "Relay denied"... But I'm using an existing email account!
          (something@thet otalsite.it) and, in fact, it works perfectly on Outlook
          Express or Visual Studio.
          Why this strange behavior? Is it a bug? How can I solve it?
          >
          Thanks in advance,
          >
          P.s.: I'm using .Net Framework 2.0.
          >
          --
          Carmine
          Webmaster di www.thetotalsite.it
          Blog http://blog.thetotalsite.it

          Comment

          • Carmine [www.thetotalsite.it]

            #6
            Re: SMTP &quot;Relay Denied&quot; on localhost! (windows server 2003)

            If you are using "localhost" or "127.0.0.1" as
            the SmtpMail.SmtpSe rver, you may not have permissions
            to relay through the IIS SMTP Service.
            To allow access, open up the IIS Admin MMC.
            Locate the SMTP Virtual Server, and right-click,
            then select Properties. On the Access tab, click the Relay button.
            In the Relay Restrictions dialog, grant your IP address (127.0.0.1)
            to the Computers listbox. Close down all dialogs,
            and restart the SMTP Service.
            Mhm, curious.
            Is it possible that the smtp is configured to grant access to all IPs except
            localhost o.O?
            And why does it send emails only to @thetotalsite.i t emails?

            Bye,

            --
            Carmine
            Webmaster di www.thetotalsite.it
            Blog http://blog.thetotalsite.it

            Comment

            Working...