Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am using default smpt virtula server to send mail using c# but it doesn't send any mails and also it doesn't throw any exceptions public static void SendEmail(string _FromEmail, string _ToEmail, string _Subject, string _EmailBody) {

    // setup email header . 
    SmtpMail.SmtpServer = "localhost";
    MailMessage _MailMessage = new MailMessage();

    _MailMessage.From = _FromEmail;
    _MailMessage.To = _ToEmail;
    _MailMessage.Subject = _Subject;
    _MailMessage.Body = _EmailBody;

    try
    {
        SmtpMail.Send(_MailMessage);
    }
    catch (Exception ex)
    {

        throw new ApplicationException("error has occured: " + ex.Message); 
    }

}

please help!

share|improve this question

1 Answer 1

I'm going to guess that the SMTP service on "localhost" is not setup properly for mail relay. This means that the mail server needs to have a parent mail server it communicates to in order for messages to be sent. This is a common mistake I see.

The MSDN article on how to setup the IIS SMTP service for mail relay should help you along. However you will need to know the DNS name of your company or ISP mail server.

http://support.microsoft.com/kb/230235

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.