title: IIS7 - sending email
body: <p>i'm totally confused about configure asp.net website to send email - hope you can help me here please</p>
  
  <p>it is running on Win 2008 R2 with IIS 7.5
  i have VS 2010 asp.net application trying to send email.</p>
  
  <p>[1] i got STMP server insatlled in this server - but unable to find "Send EMail" In Features View.. Is this an issue?</p>
  
  <p>[2] this is my code </p>
  
  <pre><code>using System.Net.Mail;
  :
  :
  //(1) Create the MailMessage instance
  MailMessage mm = new MailMessage("test@mycompany.com", "test222@mycompany.com");
  
  
  //(2) Assign the MailMessage's properties
  mm.Subject = "Subject";
  mm.Body = "the content of body here";
  mm.IsBodyHtml = true;
  
  //(3) Create the SmtpClient object
  SmtpClient smtp = new SmtpClient();
  
  //(4) Send the MailMessage (this will use the Web.config settings)
  smtp.Send(mm);
  </code></pre>
  
  <p>web.config file has </p>
  
  <pre><code>&lt;system.net&gt;
      &lt;mailSettings&gt;
        &lt;smtp deliveryMethod="Network"&gt;
          &lt;network
              host="MailServer2"
              port="25"
              userName="user_id"
              password="password"
            /&gt;
        &lt;/smtp&gt;
      &lt;/mailSettings&gt;
    &lt;/system.net&gt;
  </code></pre>
  
  <p>in my company we have a mail server (MS Exchnage server) hosted on differnt server (say MailServer2)</p>
  
  <p>so</p>
  
  <p>if i use "host=" as MailServer2 (this is mail server) - it says, <strong>"No connection could be made because the target machine actively refused "</strong></p>
  
  <p>if i use "host=" as local-host-ip - error is <strong>"Mailbox unavailable. The server response was: 5.7.1 Unable to relay for "</strong></p>
  
  <p>even i tried to config the SMTP using Start-->Admin toold-->IIS 6.0 Manager option, but no joy.</p>
  
  <p>is i'm doing anything silly? iis7 is very new to me - any help is much appricated.</p>
  
  <p>any help please?</p>
  
  <p>Cheers
  Venu</p>