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

  • Thread starter Carmine [www.thetotalsite.it]
  • Start date
C

Carmine [www.thetotalsite.it]

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("(e-mail address removed)",
(e-mail address removed), "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!
([email protected]) 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.
 
C

Carmine [www.thetotalsite.it]

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,
 
N

Norman Yuan

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.
 
C

Carmine [www.thetotalsite.it]

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,
 
S

sloan

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.
 
C

Carmine [www.thetotalsite.it]

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.

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,
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top