tags:

views:

71

answers:

1

Hello,

Basically, we bought a new server with Windows Server 2008 R2, IIS 7.5 and have set up an SMTP server. There are no special settings. The code used was working fine in Windows Server 2003, IIS6.

Here is a summary of the settings

  1. port 25, all unassigned
  2. Anonymous Access
  3. 127.0.0.1 is granted to relay access
  4. Anonymous Access set for outbound security.

I can send an email via telnet 127.0.0.1 25

The problem is I can't sent emails through a send a friend Asp.Net page.

For the ASP.NET SMTP Email in IIS7, here are my settings

  1. Deliver email to SMTP Server: 127.0.0.1, port 25
  2. Authentication Settings: Not Required

In my web.config, I have the following:

<system.net>
  <mailSettings>
    <smtp>
      <network host="127.0.0.1" port="25" />
    </smtp>
  </mailSettings>
</system.net>

Here is the code-behind code:

MailMessage M = new MailMessage();
M.Subject = subject;
.To.Add(new MailAddress(e1, f1));
M.From = new MailAddress(sendemail, sendname);
M.ReplyTo = new MailAddress(sendemail, sendname);
M.IsBodyHtml = true;
M.Body = email_message;

SmtpClient sClient = new SmtpClient();
sClient.Send(M);

Here is the event log info:

Process information: Process ID: 2840 Process name: w3wp.exe Account name: NT AUTHORITY\NETWORK SERVICE

Exception information:

  • Exception type: WebException
  • Exception message: Unable to connect to the remote server

Request information:

  • Request URL: ...
  • Request path: ...
  • User host address: ...
  • User:
  • Is authenticated: False
  • Authentication Type:
  • Thread account name: NT AUTHORITY\NETWORK SERVICE

Any ideas on why I can send email through telnet but not an asp.net page? Again, this send a friend aspx page was working fine in Windows Server 2003.

I also referenced this page, http://forums.iis.net/t/1157046.aspx and am wondering what I am missing. Thanks!

+1  A: 

I was running into that too some time ago:

This is what worked for me: (You have 2 IIS management consoles)

In IIS6 Management Console (Yes IIS 6) right click virtual server, Tab Access, Click Connection, Grant Access to 127.0.0.1, Click Relay, Grant Access to 127.0.0.1.

When it comes to IIS7, i really don't know much, i just solve the problem i run into to make my apps working. My server is professionally hosted so when it doesn't work usually one of the admins there gives me a solution or i fiddle around 'till it works.

Jeroen
Even for IIS7 you need the II6 managemet console to administer the SMTP service.
Remy