problem in sending email via SMTP service not as external senders

ⅰ亾dé卋堺 提交于 2019-12-24 18:39:40

问题


I have a problem in sending email to one of my office distributed group. The issue is as below:

Remote Server returned '550 5.7.133 RESOLVER.RST.SenderNotAuthenticatedForGroup; authentication required; Delivery restriction check failed because the sender was not authenticated when sending to this group'

By reading this blog (Link) and a few other posts, I understand in order to solve my problem, I need to run below command in Active Directory Server (ADS).

Set-DistributionGroup <group_name> -RequireSenderAuthenticationEnabled $false

which means, the problem is that the distribution group was created with default settings which means it doesn't receive email from external senders.

My questions are:

1- What does it mean "External Sender" that exchange does not accept my email in the above sentence?

2- if I do not want to run above command, how my application can pretend as it is not an external sender? (please take note that when I used outlook I could send email to that DL email and it was successful but from my application I couldn't. please advice me.

my code is in below for your reference.

using (var client = new SmtpClient("14.19.21.23"))
            {
                try
                {
                    MailMessage newMail = new MailMessage();
                    newMail.From = new MailAddress("abc@company.com", "abc@company.com");

                    newMail.To.Add(new MailAddress("DL-team@company.com", "DL-Team"));

                    newMail.Subject = "subject";
                    newMail.Body = "Mail body";
                    newMail.SubjectEncoding = Encoding.UTF8;

                    newMail.IsBodyHtml = true;
                    client.UseDefaultCredentials = false;    // true is working
                    client.Credentials = new System.Net.NetworkCredential("username", "password", "companydomain");
                    client.DeliveryMethod = SmtpDeliveryMethod.Network;

                    client.Send(newMail);
                }
                catch (Exception ex)
                {
                    throw new Exception("Sending mail failed due to :" + ex.Message, ex);
                }
            }

EDIT1: I observer that SMTP client is not using my credential! what I mean is that even if I use the wrong password there is no issue! any idea? Based on my research SMTP is using the easiest way to send mail, therefore it might use my PC details. can you share your idea? our company support below protocol[NTLM, GSSAPI]:

telnet 14.19.21.23 25
220 *****************************
EHLO www.Company.com
250-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXA
250-SIZE 37748736
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-XXXXXXXB
250-XXXXXXXXXXXXXC
250-AUTH NTLM
250-XXXXXXXXXXXXXXXXXD
250-8BITMIME
250-BINARYMIME
250-XXXXXXXE
250 XXXXF

回答1:


The problem was due to manage delivery setting.

You should change the delivery management option for “your distributed email” distributed list from “only senders inside my organization” to “Senders inside and outside of my organization.”

you can do it with below shell script also.

Set-DistributionGroup <your distribute email> -RequireSenderAuthenticationEnabled $false


来源:https://stackoverflow.com/questions/56604850/problem-in-sending-email-via-smtp-service-not-as-external-senders

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!