I've implemented an ASP.NET (C#) application which has a send email functionality. The code works well when running from Visual Studio IDE against my localhost. When running on the staging web server, I'm getting the following error message:
Mailbox unavailable. The server response was: 5.7.1 Unable to relay for someName@domainName.com
(where someName@domainName.com is the email address in the "to"-field)
<network host="hostName" port="25"/>
simplified code sequence (which also gives the error mentioned above):
public static void SendEmail(string server)
string to = "firstname.lastname@example.org";
string from = "email@example.com";
MailMessage message = new MailMessage(from, to);
message.Subject = "Some subject";
message.Body = @"Some body";
SmtpClient client = new SmtpClient();
- the hostName and port value in web.config are the values I've got from the system administrator (SA)
- there is no Default SMTP Virtual server on our IIS (which is an IIS6)
- SA does not want to install a Default SMTP Virtual server on IIS
- SA wants that the emails sendt by web applications use the hostName and port value in the web.config
- SA says I don't need a special username and password for seding email
What I tried
- added deliveryMethod="Network": <smtp deliveryMethod="Network">
- changed to: <network host="hostName" port="25" defaultCredentials="true"/
None of these helped.
- what settings/code do I need in order to solve this problem?
I've seen the error message quite a lot on Internet, but I haven't found the right solution for my scenario.