I have newly built a windows 2008 R2 server(with .NET 3.5) and added the following too IIS, SMTP, Visual Web Developer 2010 Express, but no MS Office or Outlook.
and i started SMTP server using IIS 6.0 administration (through control panel -> Admin tools -> IIS 6.0..)
And using the below code...
using System.Net;
using System.Net.Mime;
using System.Net.Mail;
public static void SendMail(string From, string To, string Subject, string BodyText)
{
MailMessage mailMsg = new MailMessage();
mailMsg.Subject = Subject;
//from and To
mailMsg.From = new MailAddress(From);
mailMsg.To.Add(new MailAddress(To);
//Body Text
mailMsg.Body = BodyText.ToString();
SmtpClient mSmtpClient = new SmtpClient();
mSmtpClient.Send(mailMsg);
// Clean up.
mailMsg.Dispose();
}
//Web.Config entry - 255.255.255.255 is the server IP
<system.net>
<mailSettings>
<smtp from="myname@gmail.com">
<network host="255.255.255.255" port="25" userName="" password=""/>
</smtp>
</mailSettings>
</system.net>
When i use the above method to send email, it shows an error "Failure Sending Mail Error", but does not give details.
As many people suggested I have also added the IP address to SMTP Server (under properties -> general tab) still shows the same message. So i'm wondering is Outlook required for sending mails from asp.net.
Please suggest what else can i check to find the actual problem and make it work.