Hi all
I must have written this code a hundred times till now. But this one seems to be not working for me. So posting here after wasting more then 10 hours trying to figure out the issue.
The story begins here......I was writing a website for a friend . He had limited resources. He booked a domain and free hosting (for 2 months but without email) on
www.smarterasp.net website.
So while developing his website and contact us form, I hosted his email on https://domains.live.com where microsoft provides 50 email ids for free for your domain and wrote this code.
MailMessage mailMessage = new MailMessage();
mailMessage.From = new MailAddress("fakeemail@mydomain.net","Travel Booking India Network",Encoding.Default);
mailMessage.To.Add("lichine7@hotmail.com");
mailMessage.Body = mailBody;
mailMessage.Subject = mailSubject;
mailMessage.IsBodyHtml = IsBodyHtml;
mailMessage.Priority = MailPriority.High;
SmtpClient client = new SmtpClient();
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("info@mydomain.net", "mysecretpassword");
client.Port = 25;
client.Host = "go.domains.live.com";
client.EnableSsl = false;
try
{
client.Send(mailMessage);
return 1;
}
catch (Exception ex)
{
throw ex;
}
But it gives me error message as - 'Failure sending email'
Stack trace is -
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 65.55.79.236:25
Source File: ......SendMail.cs Line: 47
Stack Trace:
[SocketException (0x274c): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 65.55.79.236:25]
System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +208
System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) +464
[WebException: Unable to connect to the remote server]
System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6) +6470708
System.Net.PooledStream.Activate(Object owningObject, Boolean async, GeneralAsyncDelegate asyncCallback) +307
System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) +19
System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) +324
System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint) +141
System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint) +170
System.Net.Mail.SmtpClient.GetConnection() +44
System.Net.Mail.SmtpClient.Send(MailMessage message) +1554
[SmtpException: Failure sending mail.]
SendMail.SendEmail(String mailTo, String mailSubject, String mailBody, Boolean IsBodyHtml) in q:\MatrixToursAndTravels\Working Folder\MatrixToursAndTravels\MatrixWeb\App_Code\SendMail.cs:47
ContactUs.btnCtSend_Click(Object sender, EventArgs e) in q:\MatrixToursAndTravels\Working Folder\MatrixToursAndTravels\MatrixWeb\ContactUs.aspx.cs:16
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9553178
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +103
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724
I really feel so stupid while posting this ..
Can anybody who has faced a similar problem shred some light on this?
What I tried--
1. Used different ports
2. Ssl - true/false
3. used different hosts (commnted above)
4. Tried all permutations and combinations of the above steps
and this link 5.
http://mostlygeek.com/tech/smtp-on-port-587/[
^]