By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,665 Members | 2,212 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,665 IT Pros & Developers. It's quick & easy.

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

P: n/a
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("so*******@thetotalsite.it",
so*****@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!
(so*******@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.

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

Feb 3 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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,

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

Feb 3 '08 #2

P: n/a
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.thetotalsite.it]" <pi*******@gmail.comwrote in message
news:2E**********************************@microsof t.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.SmtpClient("smtp.thetotalsite.it", 25)
Dim bodyMSG As String
bodyMSG = "something"
smtp.Send("so*******@thetotalsite.it",
so*****@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!
(so*******@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.

--
Carmine
Webmaster di www.thetotalsite.it
Blog http://blog.thetotalsite.it
Feb 3 '08 #3

P: n/a
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

Feb 3 '08 #4

P: n/a

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.


"Carmine [www.thetotalsite.it]" <pi*******@gmail.comwrote in message
news:2E**********************************@microsof t.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.SmtpClient("smtp.thetotalsite.it", 25)
Dim bodyMSG As String
bodyMSG = "something"
smtp.Send("so*******@thetotalsite.it",
so*****@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!
(so*******@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.

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

Feb 4 '08 #5

P: n/a
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,

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

Feb 4 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.