简体   繁体   English

使用SMTP设置发送邮件?

[英]Sending mail using SMTP settings?

I have a code for sending mail using SMTP settings in asp.net. 我有一个代码,可以使用asp.net中的SMTP设置发送邮件。 That code is working well on live but when i am testing the same on localhost. 该代码在现场运行良好,但是当我在localhost上对其进行测试时。 It shows the error: 它显示错误:

Mailbox unavailable. The server response was: 5.7.1 Unable to relay for abc.xyz.com

I know this is some configuration related error, but i don't know exactly what i need to change to test the same on localhost. 我知道这是一些与配置有关的错误,但是我不知道我需要更改什么才能在本地主机上测试相同的错误。 I have defined these attributes for SMTP: 我已经为SMTP定义了以下属性:

 smtp.Host = "abc.server.net";
 smtp.Port = 123; 
 smtp.EnableSsl = false;
 fromEmail="any email";
 password="password"

Any help would be appreciated. 任何帮助,将不胜感激。

You have to configure relay restrictions in the IIS admin. 您必须在IIS管理员中配置中继限制。 see this article 看这篇文章

try this 尝试这个

  1. Open IIS Manager using Control Panel --> Administrative Tools. 使用控制面板->管理工具打开IIS管理器。
  2. Open SMTP Virtual Server properties. 打开SMTP虚拟服务器属性。
  3. On General tab, Set IP address of the Web server instead of "All Unassigned". 在“常规”选项卡上,设置Web服务器的IP地址,而不是“所有未分配”。
  4. In Access tab, click on Relay button, this will open Relay Restrictions dialog. 在访问选项卡中,单击中继按钮,这将打开中继限制对话框。
  5. In relay computers list, add the loopback IP address ie 127.0.0.1 and IP address of the Web server, so that they can pass/relay emails through the SMTP server. 在中继计算机列表中,添加回送IP地址(即127.0.0.1)和Web服务器的IP地址,以便它们可以通过SMTP服务器传递/中继电子邮件。

source : SO 来源: SO

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM