Jump to content
  • Advertisement
Sign in to follow this  

[.net] SMTPClient Send Problem

This topic is 4129 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am attempting to send mail from a site on my home computer (windows xp pro). I have SMTP set up and the firewall has port 25 open. If I run the following code on a .net1.1 site it works. ------------------------------------------------------------------------------------------------- MailMessage mail=new MailMessage(); mail.To=sendtoemail; mail.From=fromemail; mail.Body=strBody; mail.Subject="Registration Confirmation"; SmtpMail.SmtpServer="127.0.0.1"; try { SmtpMail.Send(mail); } catch(Exception ex) { string errex=ex.Message; } -------------------------------------------------------------------------------------------------- But if I run the same code on a 2.0 site it does not work. Also if I use the Suggested SMTPClient code below, it also does not work. I get no errors but the mail never arrives at my inbox. --------------------------------------------------------------------------------------------------- MailMessage mail = new MailMessage(); mail.To.Add(sendtoemail); MailAddress address = new MailAddress(fromemail); mail.From = address; mail.Body = "This is a test Mail"; mail.Subject = "test mail"; try { SmtpClient snd = new SmtpClient(); snd.Host = "127.0.0.1"; snd.Send(mail); } catch (Exception ex) { string errex = ex.Message; } --------------------------------------------------------------------------------------------------- Any ideas on why the 1.1 version works but the 2.0 does not?

Share this post


Link to post
Share on other sites
Advertisement
If your not getting any errors when the code runs, but the message isn't delivered either, then Its possible that the mail service is eating the message. Turn on and/or check the mail server's logs. If nothing else this will allow you to verify that your app and the server are communicating; one less possible point of failure to eliminate.

Share this post


Link to post
Share on other sites
So then I am to understand that you are using a mail server as a relay just to test with then? And that when the message is forward on to the hotmail servers, the message just dissappears? Sounds like spam protection is your problem.

If you can, try having your app connect to your ISP's outgoing mail server. Although this can be a bit more tricky if the have auth requirements.

Share this post


Link to post
Share on other sites
I have found that it will send to my other email at blueyonder.co.uk. It is just the hotmail one that it will not send to. It is strange that I can send to the hotmail address from .net 1.1 though.

Share this post


Link to post
Share on other sites
The dns class resolves hosts a bit differently in 1.1 and 2.0. (It is used inside the smtp client)

This might be causing problems with your loopback.

You might try using "localhost" instead of 127.0.0.1

Hopefully, that will resolve better inside the smtp client.

Share this post


Link to post
Share on other sites
Ok this is really getting annoying!!!!!!!!!!

I have now moved my site up to a host server and it is still not sending to hotmail!

I have changed the host to localhost but still no luck. I thought this was a problem with my home pc's smtp server setup but now it is on the host server I presume it is a bug in .net! Every other address I send to is fine it is just hotmail accounts.

How can microsoft .net not be able to send to microsoft hotmail?

Share this post


Link to post
Share on other sites
Does the host have a name or other IP address that can be used instead.

ie.) 10.12.3.2 or whatever.
You can Query the machine for the IP address of that machine and use that. Look at the DNS class.

Share this post


Link to post
Share on other sites
Quote:
Original post by BradSnobar
Does the host have a name or other IP address that can be used instead.

ie.) 10.12.3.2 or whatever.
You can Query the machine for the IP address of that machine and use that. Look at the DNS class.


Why would this only prevent hotmail receiving the mail? It gets sent properly but hotmail accounts do not receive the mail at all (ie it is not getting tagged as spam). Yahoo receives the mails perfectly fine as do my pop3 accounts and my work account.

Share this post


Link to post
Share on other sites
This may be related - I had some similar problems when I wrote a SMTP mail sender in C++. Hotmail's mail server IP isn't the same as it's web server IP.
When you do a DNS lookup normally, you're doing a A record lookup, which returns the IP of the Hotmail web server. You need to do an MX lookup to get the IP of the mail server.

What's probably happening is you're trying to send mail to Hotmail's web server IP rather than the SMTP server IP.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!