在Windows Server 2008上配置SMTP服务器以从Web应用程序发送电子邮件

时间:2021-11-05 14:32:04

i have this web application written in C# under ASP.NET 4.0 that runs on a Windows 2008 server. I want to send emails to users from username@mydomain.com but i am unable to. I'm using the following method (which worked using smtp.gmail.com) and using System.Net.Mail;

我在ASP.NET 4.0下使用C#编写的这个Web应用程序在Windows 2008服务器上运行。我想通过username@mydomain.com向用户发送电子邮件,但我无法发送。我正在使用以下方法(使用smtp.gmail.com工作)并使用System.Net.Mail;

        string from = "user@mydomain.com";
        string password = "12345";

        MailMessage mail = new MailMessage();
        mail.To.Add(to);
        mail.From = new MailAddress(from);
        mail.Subject = title;
        mail.Body = message;
        mail.IsBodyHtml = true;

        SmtpClient smtp = new SmtpClient();
        smtp.Host = "stmp ip here";
        smtp.Port = 25;
        smtp.Credentials = new System.Net.NetworkCredential(from, password);
        smtp.EnableSsl = false;

        smtp.Send(mail);

I have installed and configure SMTP server using basic authentication and outbound security -> basic authentication (using user@mydomain.com and 12345 as password). In IIS7 on my website i clicked on SMTP E-mail and entered the ip of my SMTP server together with the credentials from above.

我已使用基本身份验证和出站安全性 - >基本身份验证(使用user@mydomain.com和12345作为密码)安装和配置SMTP服务器。在我网站上的IIS7中,我点击了SMTP电子邮件,并输入了我的SMTP服务器的IP以及上面的凭据。

Before doing all this config, i run into problems like the emails being stuck in the queue folder, server does not support ssl connections and others. Now, the only error i receive when sending email is logged from my application: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.3 Client was not authenticated and the email is not arriving at destination. The Queue folder is empty and i don't have any errors from the SMTP server log!

在进行所有这些配置之前,我遇到的问题包括电子邮件卡在队列文件夹中,服务器不支持ssl连接等。现在,从我的应用程序记录发送电子邮件时收到的唯一错误:SMTP服务器需要安全连接或客户端未经过身份验证。服务器响应为:5.7.3客户端未经过身份验证,并且电子邮件未到达目标。 Queue文件夹为空,我没有SMTP服务器日志中的任何错误!

I did alot of research on google about it but i can't fix it. Telnet is working as it should, port 25 is not blocked and disabling windows firewall is not helping either. I'm really stuck. Any ideas? Thanks!

我在google上做了很多关于它的研究,但我无法修复它。 Telnet正常工作,端口25未被阻止,禁用Windows防火墙也没有帮助。我真的被卡住了。有任何想法吗?谢谢!

1 个解决方案

#1


1  

Sounds like the server may require you to set 'EnableSsl' to 'true'. So, you could either try to disable this on your server or simply set 'EnableSSl = true' in your client. You will probably then need to change the port to 587 or (sometimes) 465.

听起来服务器可能会要求您将'EnableSsl'设置为'true'。因此,您可以尝试在服务器上禁用此功能,也可以在客户端中设置“EnableSSl = true”。您可能需要将端口更改为587或(有时)465。

#1


1  

Sounds like the server may require you to set 'EnableSsl' to 'true'. So, you could either try to disable this on your server or simply set 'EnableSSl = true' in your client. You will probably then need to change the port to 587 or (sometimes) 465.

听起来服务器可能会要求您将'EnableSsl'设置为'true'。因此,您可以尝试在服务器上禁用此功能,也可以在客户端中设置“EnableSSl = true”。您可能需要将端口更改为587或(有时)465。