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]