【发布时间】:2010-07-17 12:50:04
【问题描述】:
我在 IIS 中管理 SMTP 服务器配置,以通过 asp 发送电子邮件作为中继部分我添加了我的 PC IP 传递>高级我在智能主机中添加了我的域名作为 mail.elarabygroup.com。
我添加了这段代码:
<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(
"karim-gamal@elarabygroup.com", "From Kareem Test");
MailAddress toAddress = new MailAddress(
"fady-eltegany@elarabygroup.com", "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>
但是出现错误:
邮箱不可用。服务器响应为:5.7.1 Unable to relay for fady-eltegany@larabygroup.com
【问题讨论】:
标签: iis asp-classic smtp