locked
.NET MailMessage RRS feed

  • Question

  • I have the code to send email from ASP.NET(C#) using SMTP. But how will i know it is actually sent.
    I mean to say i just have to have a look that it is actually delivered. But whenever I specify some Email ID it doesn't work and throws an error. Error is as follows:

    "Mailbox unavailable. The server response was: 5.7.1 Unable to relay for abc@mail.com "

    My code is as follows:

    MailMessage msgMail = new MailMessage("f11@mail.com", "abc@yahoo.com");
            msgMail.Body = "Hello";
            SmtpClient smtp = new SmtpClient("localhost");
            smtp.Send(msgMail);
           
            Response.Write("Email Sent!!");


    Really be grateful if some replies.
    • Moved by nobugz Monday, June 29, 2009 9:11 PM (From:.NET Base Class Library)
    Monday, June 29, 2009 9:03 PM

Answers

  • It could be possible that your email server requires authentication. Also it could be possible that SSL is required by your server. Normally port number required for sending email is 25 but it could also be different. You need to check for all this before sending email successfully.

    Below link contains example for sending email using SMTPClient

    http://gauravkhanna.blog.co.in/2008/07/13/send-email-from-your-gmail-account/
    Gaurav Khanna
    • Proposed as answer by Khanna Gaurav Tuesday, July 7, 2009 6:32 PM
    • Marked as answer by debopam1988 Wednesday, July 8, 2009 12:53 PM
    Tuesday, June 30, 2009 10:59 AM

All replies

  • It could be possible that your email server requires authentication. Also it could be possible that SSL is required by your server. Normally port number required for sending email is 25 but it could also be different. You need to check for all this before sending email successfully.

    Below link contains example for sending email using SMTPClient

    http://gauravkhanna.blog.co.in/2008/07/13/send-email-from-your-gmail-account/
    Gaurav Khanna
    • Proposed as answer by Khanna Gaurav Tuesday, July 7, 2009 6:32 PM
    • Marked as answer by debopam1988 Wednesday, July 8, 2009 12:53 PM
    Tuesday, June 30, 2009 10:59 AM
  • Thanks Mr. Gaurav Khanna. I went through your blog. Its really helpful..
    Tuesday, July 7, 2009 1:47 PM