tags:

views:

47

answers:

1

I had Managed SMTP server configurations in IIS to send email through asp as relay section I added My PC IP Delivery>Advanced I add My Domain name as mail.elarabygroup.com in smart host.

And I added this code:

<script runat="server">
        protected void SendEmail(object sender, EventArgs e)
        {
            SmtpClient smtpClient = new SmtpClient();
            MailMessage message = new MailMessage();
            try
            {
                // Prepare two email addresses
                MailAddress fromAddress = new MailAddress(
                "[email protected]", "From Kareem Test");
                MailAddress toAddress = new MailAddress(
                "[email protected]", "From Kareem Test");
                // Prepare the mail message

                message.From = fromAddress;
                message.To.Add(toAddress);
                message.Subject = "Testing!";
                message.Body = "This is the body of a sample message";
                // Set server details
                smtpClient.Host = "localhost";
                // Uncomment for SMTP servers that require authentication
                //smtpClient.Credentials = new System.Net.NetworkCredential(
                // "user", "password");
                // Send the email
                smtpClient.Send(message);
                // Inform the user
                statusLabel.Text = "Email sent.";
            }
            catch (Exception ex)
            {
                // Display error message
                statusLabel.Text = "Coudn't send the message!";
            }
        }
    </script>

But an error occurs:

Mailbox unavailable. The server response was: 5.7.1 Unable to relay for [email protected]

A: 

Talk to the administrator of the email server. You are apparently not allowed to relay by default, so you may need to provide a login/password combo to the server (see the NetworkCredentials in your snippet).

You indicate your relay may be mail.elarabygroup.com---is the "e" in there intentional; it's different from the domain you use in the example? That might be the reason you're not allowed to relay.

ShiDoiSi
the "e" I missed it but it didnot the reason .Also [email protected] I use it through outlook to send and reciev emails .
KareemSaad
I fogot to tell that I work in VM ware
KareemSaad
[Don't](http://meta.stackoverflow.com/questions/46035/should-i-remove-tags-that-dont-contribute-to-categorizing-the-question/46037#46037) [tag](http://meta.stackoverflow.com/questions/43879/anti-tags-valid-use-or-not) [not-programming-related.](http://meta.stackoverflow.com/questions/10216/can-we-disallow-the-use-of-belongs-on-xxxxxxx-and-not-programming-related-tag/10222#10222) (Also, a name with 3 letters, so [comment replies](http://meta.stackoverflow.com/questions/43019/how-do-comment-replies-work) work, would be helpful. :)
Roger Pate