Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / February 2008

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Carmine [www.thetotalsite.it] - 03 Feb 2008 01:40 GMT
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.SmtpClient("smtp.thetotalsite.it", 25)
                   Dim bodyMSG As String
                   bodyMSG = "something"
                   smtp.Send("something@thetotalsite.it",
someone@gmail.com, "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.SmtpFailedRecipientException: Mailbox unavailable. The
server response was: Relay denied
  at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender,
MailAddressCollection recipients, String deliveryNotify,
SmtpFailedRecipientException& exception)
  at System.Net.Mail.SmtpClient.Send(MailMessage message)
  at System.Net.Mail.SmtpClient.Send(String from, String recipients, String
subject, String body)
  at controls_comments.Submit_Click(Object sender, EventArgs e)

So, "Relay denied"... But I'm using an existing email account!
(something@thetotalsite.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.

Signature

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

Carmine [www.thetotalsite.it] - 03 Feb 2008 01:50 GMT
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.it" and
in the FROM field the same email address (with the domain
"thetotalsite.it")...
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,

Signature

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

Norman Yuan - 03 Feb 2008 15:34 GMT
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.

> Hi everyone,
> I get a really odd error while using SMTPClient.Send() function in
[quoted text clipped - 33 lines]
>
> P.s.: I'm using .Net Framework 2.0.
Carmine [www.thetotalsite.it] - 03 Feb 2008 15:54 GMT
> 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,

Signature

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

sloan - 04 Feb 2008 03:38 GMT
Try this homemade library:
http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!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.SmtpServer, 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.

> Hi everyone,
> I get a really odd error while using SMTPClient.Send() function in
[quoted text clipped - 33 lines]
>
> P.s.: I'm using .Net Framework 2.0.
Carmine [www.thetotalsite.it] - 04 Feb 2008 12:03 GMT
>      If  you are using "localhost" or "127.0.0.1" as
>      the SmtpMail.SmtpServer, you may not have permissions
[quoted text clipped - 5 lines]
>      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.it emails?

Bye,

Signature

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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.