.Net Sending SMTP Mail from dev machine (not server) utilizing hmailserver

940 Views Asked by At

I've been trying to figure out how to make my smtp mail to work. I have my dev environment set up on my computer, it currently uses Windows 7 home premium. Whenever I'm done doing changes I'd publish it to my host. Now I have a few site functionality that requires sending emails. When the site is published it works fine, but when on my localhost it would always fail. I've been reading a few forum posts and SO questions and it seems to me that I have to install a smtp application? I have picked hMailServer as it's the most common one I see. My problem is though I'm not sure if I have set it up correctly. When I build and run my site, it would still throw the same error (Failure sending mail).

This is my code:

try
{
    System.Net.Mail.SmtpClient SMTP = new System.Net.Mail.SmtpClient(); 
                    SMTP.Credentials = new System.Net.NetworkCredential("[email protected]", "ghandi");
                    SMTP.Host = "mail.mydomainexample.com";
                    SMTP.Port = 25;

    SMTP.Send(Email);

            }catch (SmtpException smtpEx)
            {
                throw new SmtpException("SMTP Exception. " + smtpEx.Message);
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Error on Sending Mail. " + ex.Message);
            }

Can anybody point me to the right direction as to how I can make sure the smtp application is working.

NOTE: I've followed the following link in configuring my hMailServer installation:

http://support.moonpoint.com/network/email/hmailserver/

However, I am stuck in this area:

"When you set the value for the local host name, if you telnet to port 25 on the server, you will see it listed in the banner returned by the server."

0

There are 0 best solutions below