Microsoft Exchange中继访问被拒绝

时间:2018-09-09 03:19:36

标签: c# outlook smtp exchange-server

大家好!

我再次发布问题,但有其他描述。在我们组织中使用Microsoft Exchange作为内部邮件。在我这方面,我负责安装一个Web API,该API允许使用我们的domain.com无重放帐户将电子邮件发送到外部组织。 我在Windows应用程序上模拟了此功能,但仍然收到消息: {“不允许客户端向此服务器提交邮件。”服务器响应为:4.7.1:中继访问被拒绝“}

private void button2_Click(object sender, EventArgs e)
    {
        string Username = "MyUN";
        string Password = "MyPW";
        string SmtpServer = "Doamine";
        string From = Username + "@SmtpServer";

        System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient();
        NetworkCredential basicCredential = new NetworkCredential(Username, Password, SmtpServer);
        MailMessage message = new MailMessage();
        System.Net.Mail.MailAddress fromAddress = new System.Net.Mail.MailAddress(From);

        // setup up the host, increase the timeout to 5 minutes
        smtpClient.Host = SmtpServer;
        smtpClient.Port = 25;
        smtpClient.Credentials = basicCredential;
        //smtpClient.UseDefaultCredentials = true;
        smtpClient.EnableSsl = true; ;
        smtpClient.Timeout = (60 * 5 * 1000);

        message.From = fromAddress;
        message.Subject = " - " + DateTime.Now.Date.ToString().Split(' ')[0];
        message.IsBodyHtml = true;
        message.Body = " -88888888888888888888888888888 ";
        message.To.Add("Receipt@gmail.com");
        ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };


        smtpClient.Send(message);
    }

我使用了带有用户名和密码的身份验证,以及通过启用//smtpClient.UseDefaultCredentials = true的Windows身份验证;但仍然是同样的错误。

请问您有什么想法,并在此先感谢您!!!!

0 个答案:

没有答案