IIS7 - 发送电子邮件

发布于 2025-01-04 03:31:09 字数 1651 浏览 1 评论 0原文

我对配置 ASP.NET 网站发送电子邮件感到完全困惑 - 希望您能在这里帮助我,

它运行在带有 IIS 7.5 的 Win 2008 R2 上 我有 VS 2010 asp.net 应用程序尝试发送电子邮件。

[1] 我在此服务器中安装了 STMP 服务器 - 但无法在功能视图中找到“发送电子邮件”。这是一个问题吗?

[2] 这是我的代码

using System.Net.Mail;
:
:
//(1) Create the MailMessage instance
MailMessage mm = new MailMessage("[email protected]", "[email protected]");


//(2) Assign the MailMessage's properties
mm.Subject = "Subject";
mm.Body = "the content of body here";
mm.IsBodyHtml = true;

//(3) Create the SmtpClient object
SmtpClient smtp = new SmtpClient();

//(4) Send the MailMessage (this will use the Web.config settings)
smtp.Send(mm);

web.config 文件,

<system.net>
    <mailSettings>
      <smtp deliveryMethod="Network">
        <network
            host="MailServer2"
            port="25"
            userName="user_id"
            password="password"
          />
      </smtp>
    </mailSettings>
  </system.net>

在我的公司中,我们有一个邮件服务器(MS Exchnage 服务器)托管在不同的服务器(例如 MailServer2)上,

所以

如果我使用“host=”作为 MailServer2(这是邮件服务器)-它说,“无法建立连接,因为目标计算机主动拒绝”

如果我使用“host =”作为本地主机IP - 错误是“邮箱不可用。服务器响应是: 5.7.1 无法中继对于“

即使我尝试使用“开始”-->“管理工具”-->“IIS 6.0 管理器”选项来配置 SMTP,但没有任何乐趣。

我是在做傻事吗? iis7 对我来说很新 - 任何帮助都非常有用。

有什么帮助吗?

干杯 维努

i'm totally confused about configure asp.net website to send email - hope you can help me here please

it is running on Win 2008 R2 with IIS 7.5
i have VS 2010 asp.net application trying to send email.

[1] i got STMP server insatlled in this server - but unable to find "Send EMail" In Features View.. Is this an issue?

[2] this is my code

using System.Net.Mail;
:
:
//(1) Create the MailMessage instance
MailMessage mm = new MailMessage("[email protected]", "[email protected]");


//(2) Assign the MailMessage's properties
mm.Subject = "Subject";
mm.Body = "the content of body here";
mm.IsBodyHtml = true;

//(3) Create the SmtpClient object
SmtpClient smtp = new SmtpClient();

//(4) Send the MailMessage (this will use the Web.config settings)
smtp.Send(mm);

web.config file has

<system.net>
    <mailSettings>
      <smtp deliveryMethod="Network">
        <network
            host="MailServer2"
            port="25"
            userName="user_id"
            password="password"
          />
      </smtp>
    </mailSettings>
  </system.net>

in my company we have a mail server (MS Exchnage server) hosted on differnt server (say MailServer2)

so

if i use "host=" as MailServer2 (this is mail server) - it says, "No connection could be made because the target machine actively refused "

if i use "host=" as local-host-ip - error is "Mailbox unavailable. The server response was: 5.7.1 Unable to relay for "

even i tried to config the SMTP using Start-->Admin toold-->IIS 6.0 Manager option, but no joy.

is i'm doing anything silly? iis7 is very new to me - any help is much appricated.

any help please?

Cheers
Venu

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

机场等船 2025-01-11 03:31:09

在 MailServer2 上,如果该计算机上确实运行着 SMTP 服务器,则它可能位于不同的端口上。错误消息表明 SMTP 服务器未在端口 25 上运行。

当您将其指向本地 IP 时,会出现此错误消息:

邮箱不可用。服务器响应是: 5.7.1 无法中继“

实际上来自 SMTP 服务器。一切正常。现在,您只需更改 SMTP 服务器中的设置以允许本地主机或您的帐户中继(您不需要不要说明您正在使用什么 SMTP 服务器,除非它是本地安装的)

--hth,
戴夫

On MailServer2, if there actually is a SMTP server running on that machine, it is probably on a different port. The error message says the SMTP server isn't running on port 25.

When you point it at the local IP, this error message:

Mailbox unavailable. The server response was: 5.7.1 Unable to relay for "

Is actually coming from the SMTP server. Everything is working correctly. Now, you just need to change the setting in your SMTP server to allow relay for localhost or your account (you don't say what SMTP server you are using, other than it's installed locally).

--hth,
Dave

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文