views:

645

answers:

3

I have this code to send mail:

public bool SendMail(MailMessage message)
{
    message.From = new MailAddress(AppProperties.FromMailAddress, AppProperties.FromDisplayName);
    SmtpClient smtp = new SmtpClient { EnableSsl = AppProperties.EnableSsl };
    try
    {
        smtp.Send(message);
        return true;
    }
    catch (Exception)
    {
        return false;
    }
}

and have configured web.config to send mail using IIS 5.1 in localhost with this (as suggested by the answers):

  <system.net>
    <mailSettings>
      <smtp deliveryMethod="Network">
        <network host="localhost"
                 userName=""
                 password=""
                 defaultCredentials="false"
                 port="25" />
      </smtp>
    </mailSettings>
  </system.net>

What do I have to do to send mail with my IIS 5.1 in Windows XP? Is possible to do it? I guess yes, as you say, since I don't get any exception, but I don't receive it on destination. If I should put an user and a password, wich must be?

Thanks in advanced.

+1  A: 

Sure it's possible, you will no longer need to use SSL however. In the config file, your port will probably be 25, you may or may not need username/password, and of course your hostname will change.

Also make sure you install the SMTP components along with IIS.

Dan
A: 

yes you can send it this way :D (but i think you need to use port 25) smtp class is part of .net

Yassir
+1  A: 

You should first install SMTP server (Windows Components > IIS > SMTP Service) and then configure it to enable relaying.

IIS > Default SMTP Server > Properties Access > Authentication

Access Control > Anonymous Access - Checked

Relay Restrictions > Relay > Select - Only the list below > Add > 127.0.0.1

awaisj