I have Windows XP and configured SMTP server in my IIS. Specified AllUnAssigned in IP address of general tab and specified 127.0.0.1 in connection under Access tab.
Now I tried sending mails using my local SMTP server using the following code,
MailMessage amessage = new MailMessage();
amessage.To.Add(new MailAddress("xxx@gmail.com"));
amessage.From = new MailAddress("yyy@gmail.com");
amessage.Subject = "TestMail";
amessage.Body = "This is a testmail";
SmtpClient clienta = new SmtpClient("localhost");
clienta.Timeout = 500;
clienta.Credentials = CredentialCache.DefaultNetworkCredentials;
try
{
clienta.Send(amessage);
}
catch (Exception ex)
{
Console.WriteLine(ex);
Console.ReadLine();
}
Console.ReadLine();
I don’t get any error in executing the above code but no mails were sent/received. When I checked in the Inetpub I find the below file:
From: postmaster@munged
To: yyy@gmail.com
Date: Tue, 26 Apr 2011 11:07:22 +0530
MIME-Version: 1.0
Content-Type: multipart/report;
report-type=delivery-status;
boundary=”9B095B5ADSN=_01CC03D260FE2C6C00000003munged?xxx”
Message-ID:Subject: Delivery Status Notification
(Failure)This is a MIME-formatted message.
Portions of this message may be
unreadable without a MIME-capable mail
program.–9B095B5ADSN=_01CC03D260FE2C6C00000003munged?munged
Content-Type: text/plain;
charset=unicode-1-1-utf-7This is an automatically generated
Delivery Status Notification.Delivery to the following recipients
failed.xxx@gmail.com–9B095B5ADSN=_01CC03D260FE2C6C00000003munged?munged
Content-Type: message/delivery-statusReporting-MTA: dns;munged
Received-From-MTA: dns;munged
Arrival-Date: Tue, 26 Apr 2011
11:07:16 +0530Final-Recipient: rfc822;xxx@gmail.com
Action: failed Status: 5.0.0
Diagnostic-Code: smtp;550-5.7.1
[122.178.191.78] The IP you’re using
to send mail is not authorized to
550-5.7.1 send email directly to our
servers. Please use the SMTP relay at
your 550-5.7.1 service provider
instead. Learn more at
550 5.7.1
http://mail.google.com/support/bin/answer.py?answer=10336
m9si19863225wfl.114–9B095B5ADSN=_01CC03D260FE2C6C00000003munged?munged
Content-Type: message/rfc822Received: from munged
([127.0.0.1]) by munged with
Microsoft SMTPSVC(6.0.2600.2180);
Tue, 26 Apr 2011 11:07:16 +0530
MIME-Version: 1.0 From: yyy@gmail.com
To: xxx@gmail.com Date: 26 Apr 2011
11:07:16 +0530 Subject: TestMail
Content-Type: text/plain;
charset=us-ascii
Content-Transfer-Encoding:
quoted-printable Return-Path:
munged@gmail.com Message-ID:X-OriginalArrivalTime: 26 Apr 2011
05:37:16.0515 (UTC)
FILETIME=[009D2330:01CC03D4]This is a testmail
–9B095B5ADSN=_01CC03D260FE2C6C00000003munged?munged–
Can anyone please help me on this?
Here’s the important part of the error message:
To solve this, you’ll need to setup an SMTP relay to send to your ISP’s email servers. They’ll send to Google for you.
For clarity:
smtp.yourISP.com.