문제

현재 특정 발신자의 모든 발신 메일로 일부 헤더를 교체하기 위해 Exchange 2007 운송 에이전트를 작성하고 있습니다. 'From'SMTP 헤더를 성공적으로 교체했지만 'Return-Path'헤더를 다시 작성하는 것은 작동하지 않는 것 같습니다.

이 모든 일을하기 위해, 나는 맞춤형 smtpreceiveagent를 작성하고 다음과 같은 onendofdata 이벤트를 구독했습니다.

private static void MyAgent_OnEndOfData(ReceiveMessageEventSource source, EndOfDataEventArgs e)
        {

            try
            {
                var address = e.MailItem.Message.From.SmtpAddress;
                if (address.ToLower().EndsWith("[internal email domain]"))
                {
                    // replace the From: header - WORKING FINE!
                    e.MailItem.Message.From = new EmailRecipient("[displayname]",
                                                                 "[email address]");

                    // replace the Return-Path: header - NOT WORKING!
                    var headerList = e.MailItem.Message.RootPart.Headers;
                    var header = (AddressHeader)headerList.FindFirst("Return-Path");
                    var newheader = new AddressHeader("Return-Path") { Value = "[email address" };
                    headerList.ReplaceChild(newheader, header);
                }
            }
            catch (Exception ex)
            {
               // do something useful here
            }

        }
도움이 되었습니까?

해결책

RFC에 따라 리턴 패스 헤더는 수신자의 SMTP 서버에 의해 설정되어야합니다. 이메일에 리턴 패스 헤더가 존재하는 경우 수신자의 서버에서 제거하고 재설정됩니다.

어쩌면 당신이보고있는 것은 RFC의 올바른 구현 일 것입니다.

다른 팁

확실하지 않지만 "Retud-Path"가 아닌 "Reply-to"헤더를 변경하고 싶을 것 같습니다. "Return-Path"는 서버에서 설정해야합니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top