通过 SMTP 从内部电子邮件地址发送电子邮件 - 邮箱不可用或不是本地的 (.NET 4)
我的问题是我无法发送从服务器上托管的收件人发送的 SMTP 电子邮件。我的联系表单适用于以发件人收件人作为外部电子邮件地址的电子邮件,但现在我需要我的系统之一将电子邮件从同一服务器上托管的域发送到任何其他提供的电子邮件(订阅者),它只是给了我错误:
发送电子邮件时出错:邮箱 不可用。服务器响应是: 请求的操作未执行:邮箱 不可用或不在本地
我正在 windows 服务器 上使用 IIS7 运行 mailEnable,想知道是否有人遇到此问题?我已经通过 Outlook 使用上述详细信息测试了邮箱,它可以正常发送/接收电子邮件。下面是一个代码示例,显示了我正在使用的内容,据我所知,它应该可以很好地进行身份验证。我还尝试将配置设置移回到 C# 代码中,但遇到了同样的问题。
web.config 示例:
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="[email protected]">
<network defaultCredentials="true" host="mail.test.com" port="25" userName="[email protected]" password="******" />
</smtp>
</mailSettings>
</system.net>
C# .NET 4 代码示例:
try
{
_emailMsg.Body = _MessageBody;
_emailMsg.Priority = MailPriority.Normal;
SmtpClient mSmtpClient = new SmtpClient();
mSmtpClient.UseDefaultCredentials = true;
mSmtpClient.Send(_emailMsg);
return true;
}
catch (Exception ex)
{
throw new Exception("Error Sending Email: " + ex.Message);
return false;
}
My problem is that I can't send SMTP emails sent from a recipient hosted on my server. I have contact forms that work fine for emails with a from recipient as an external email address but now I require one of my systems to send emails from a domain hosted on the same server to any other provided email (subscriber) and it just gives me the error:
Error Sending Email: Mailbox
unavailable. The server response was:
Requested action not taken: mailbox
unavailable or not local
I am running mailEnable on a windows server with IIS7 and wondered if anyone was having this problem? I have tested the mailbox using the details above through outlook and it send / receives emails fine. Here is a code sample below showing what I'm using and as far as I know it should be authenticating fine. I also tried moving the config settings back into the C# code and had the same issue.
Example web.config:
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="[email protected]">
<network defaultCredentials="true" host="mail.test.com" port="25" userName="[email protected]" password="******" />
</smtp>
</mailSettings>
</system.net>
Example C# .NET 4 code:
try
{
_emailMsg.Body = _MessageBody;
_emailMsg.Priority = MailPriority.Normal;
SmtpClient mSmtpClient = new SmtpClient();
mSmtpClient.UseDefaultCredentials = true;
mSmtpClient.Send(_emailMsg);
return true;
}
catch (Exception ex)
{
throw new Exception("Error Sending Email: " + ex.Message);
return false;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看 MailEnable 的网站,有一些有关错误消息的指南这可能会发生。
进一步猜测,您的域名似乎存在于网络服务器上,并且那里没有问题,但您必须明确地将任何电子邮件地址列入白名单
address-map.tab
文件。关于这个问题还有更多注释,其完整解决方案是:Looking at MailEnable's website, there is some guidance on the error messages that might occur.
Guessing a bit further, it appears that your domain name exists on the web server and there is no issue there, but you have to explicitly white-list any email addresses in the
address-map.tab
file. There are more notes on the issue and their resolution in full is:使用这个:
Use this: