dovecot 및 Simple Content Filter(Postfix)를 사용하여 Always_bcc에 중복 메시지 전달

dovecot 및 Simple Content Filter(Postfix)를 사용하여 Always_bcc에 중복 메시지 전달

다음을 사용하여 트래픽이 매우 적은 postfix 메일 서버를 설정하려고 합니다.

  • 간단한 콘텐츠 필터(http://www.postfix.org/FILTER_README.html#simple_filter). 고급 버전보다 훨씬 간단하고 트래픽도 적습니다.
  • 배달 대리인으로서의 비둘기장. (maildir 할당량 및 체 필터 때문에)
  • always_bcc전송된 모든 메일의 사본을 보관합니다. (비즈니스 규칙)

내 관련 구성은 다음과 같습니다

master.cf

smtp      inet  n       -       y       -       -       smtpd
        -o content_filter=filter:dummy
pickup    unix  n       -       y       60      1       pickup
cleanup   unix  n       -       y       -       0       cleanup
qmgr      unix  n       -       n       300     1       qmgr
tlsmgr    unix  -       -       y       1000?   1       tlsmgr
rewrite   unix  -       -       y       -       -       trivial-rewrite
bounce    unix  -       -       y       -       0       bounce
defer     unix  -       -       y       -       0       bounce
trace     unix  -       -       y       -       0       bounce
verify    unix  -       -       y       -       1       verify
flush     unix  n       -       y       1000?   0       flush
proxymap  unix  -       -       n       -       -       proxymap
proxywrite unix -       -       n       -       1       proxymap
smtp      unix  -       -       y       -       -       smtp
relay     unix  -       -       y       -       -       smtp
        -o syslog_name=postfix/$service_name
showq     unix  n       -       y       -       -       showq
error     unix  -       -       y       -       -       error
retry     unix  -       -       y       -       -       error
discard   unix  -       -       y       -       -       discard
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       y       -       -       lmtp
anvil     unix  -       -       y       -       1       anvil
scache    unix  -       -       y       -       1       scache
postlog   unix-dgram n  -       n       -       1       postlogd
uucp      unix  -       n       n       -       -       pipe
  flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
filter    unix  -       n       n       -       10      pipe
  flags=Rq user=filter null_sender=
  argv=/var/spool/filter/scripts/filter.sh -f ${sender} -- ${recipient}
dovecot    unix  -       n       n       -       -       pipe
  flags=DRhu user=vmail:mail argv=/usr/lib/dovecot/dovecot-lda -f ${sender} -d ${recipient}

main.cf (관련 부분만)

always_bcc = [email protected]
virtual_transport = dovecot
dovecot_destination_recipient_limit = 1

/var/spool/filter/scripts/filter.sh

#!/bin/sh

/usr/bin/cat | /var/spool/filter/scripts/mailfilter | /usr/sbin/sendmail -G -i "$@"

exit $?

  • 내 모든 사용자의 이메일은 '(초기)에 있습니다.[이메일 보호됨]" 형식
  • 역할을 수행하는 보안 그룹이 있으며 각 보안 그룹에는 "[이메일 보호됨]" 형식입니다.
  • 기본적으로 역할 이메일은 여러 사용자에 대한 별칭으로 작동합니다.

따라서 사용자를 직접 사용하지 않고 권한을 설정하는 데 사용하는 것과 동일한 역할/그룹을 재사용할 수 있습니다.

예를 들어

  • 내 사용자 이메일은[이메일 보호됨]
  • 저는 ITDepartment([이메일 보호됨])
  • 나는 다른 역할의 구성원이지만 내 주요 역할은 "ITDepartment"입니다.
  • 나는 이 그룹/역할의 구성원이기 때문에 다른 구성원 및 다음으로 전송되는 모든 메일과 마찬가지로 특정 권한을 갖습니다.[이메일 보호됨]나와 다른 멤버들에게 닿을 거예요.

지금까지는 아주 좋았습니다... 하지만 상사는 제가 보내는 모든 메일에[이메일 보호됨](역할) 주소 대신[이메일 보호됨](사용자). 즉, 전송된 모든 메일은 사용자 이메일이 아닌 주 역할 이메일을 사용합니다.

/var/spool/filter/scripts/mailfilter이 작업을 수행하는 자체 제작 필터입니다(LDAP 서버를 확인하여 "from" 주소를 "(초기).surname@"에서 "role@"으로 변경).

절대 실패하지 않습니다(오류 조건이 발생하는 경우 표준 입력을 표준 출력으로 복사하고 수정이 이루어지지 않으므로 주소는 변경되지 않지만 메일은 손실되지 않습니다).

문제는 내가 이메일을 보내면 두 개의 사본이 다음 주소로 전달된다는 것입니다.[이메일 보호됨]로그에 표시된 대로 예상대로 복사본이 하나도 없습니다.


Dec 16 16:23:08 correo2 postfix/smtpd[32453]: connect from informatica1.mydomain.example[10.128.159.15]
Dec 16 16:23:08 correo2 postfix/smtpd[32453]: DD925380C87: client=informatica1.mydomain.example[10.128.159.15], sasl_method=LOGIN, [email protected]
Dec 16 16:23:08 correo2 postfix/cleanup[32456]: DD925380C87: message-id=<[email protected]>
Dec 16 16:23:09 correo2 postfix/qmgr[32275]: DD925380C87: from=<[email protected]>, size=2749, nrcpt=2 (queue active)
Dec 16 16:23:09 correo2 postfix/pickup[32274]: AAFEF380C8D: uid=110 from=<[email protected]>
Dec 16 16:23:09 correo2 postfix/pipe[32457]: DD925380C87: to=<[email protected]>, relay=filter, delay=0.81, delays=0.11/0/0/0.7, dsn=2.0.0, status=sent (delivered via filter service)
Dec 16 16:23:09 correo2 postfix/pipe[32457]: DD925380C87: to=<[email protected]>, orig_to=<[email protected]>, relay=filter, delay=0.81, delays=0.11/0/0/0.7, dsn=2.0.0, status=sent (delivered via filter service)
Dec 16 16:23:09 correo2 postfix/qmgr[32275]: DD925380C87: removed
Dec 16 16:23:09 correo2 postfix/cleanup[32456]: AAFEF380C8D: message-id=<[email protected]>
Dec 16 16:23:09 correo2 postfix/qmgr[32275]: AAFEF380C8D: from=<[email protected]>, size=2927, nrcpt=3 (queue active)
Dec 16 16:23:10 correo2 dovecot: lda([email protected])<32488><2DSfML3hnGPofgAA0V72BQ>: msgid=<[email protected]>: saved mail to INBOX
Dec 16 16:23:10 correo2 postfix/pipe[32473]: AAFEF380C8D: to=<[email protected]>, relay=dovecot, delay=1.1, delays=0.79/0/0/0.28, dsn=2.0.0, status=sent (delivered via dovecot service)
Dec 16 16:23:10 correo2 dovecot: lda([email protected])<32490><Au2fML3hnGPqfgAA0V72BQ>: msgid=<[email protected]>: saved mail to INBOX
Dec 16 16:23:10 correo2 postfix/pipe[32471]: AAFEF380C8D: to=<[email protected]>, relay=dovecot, delay=1.1, delays=0.79/0/0/0.34, dsn=2.0.0, status=sent (delivered via dovecot service)
Dec 16 16:23:10 correo2 dovecot: lda([email protected])<32489><BE2gML3hnGPpfgAA0V72BQ>: msgid=<[email protected]>: saved mail to INBOX
Dec 16 16:23:10 correo2 postfix/pipe[32470]: AAFEF380C8D: to=<[email protected]>, relay=dovecot, delay=1.1, delays=0.79/0/0/0.35, dsn=2.0.0, status=sent (delivered via dovecot service)
Dec 16 16:23:10 correo2 postfix/qmgr[32275]: AAFEF380C8D: removed
Dec 16 16:23:11 correo2 postfix/smtpd[32453]: disconnect from informatica1.mydomain.example[10.128.159.15] ehlo=1 auth=1 mail=1 rcpt=1 data=1 quit=1 commands=6

uid=110은 "필터" 사용자 uid입니다. "보낸 사람"은 이메일 내부의 헤더에서만 변경되므로 로그에는 표시되지 않습니다.

이 이중 전달 세부 사항을 제외하고 모든 것이 정상적으로 실행되고 있습니다. 시도하지는 않았지만 방정식에서 비둘기장을 제거하면 모든 것이 작동할 것이라고 확신합니다. 그러나 나는 체 규칙과 maildir 할당량을 잃습니다. 그래서...

어떻게 고칠 수 있는지 아시나요?

답변1

Tl;dr: 원본 이메일은 Always_bcc를 추가하고 복사본을 보내는 Postfix에 도착하고 필터에 따라 이메일을 삭제합니다. 필터는 Always_bcc를 추가하고 복사본을 보낸 다음 이메일을 전달하는 Postfix에 새 메시지를 보냅니다.

마지막 세 문단을 읽어보세요.


Postfix에 도달하는 첫 번째 이메일이 원본이 됩니다.DD925380C87seccopies, 따라서 다음과 같이 해당 사본을 바로 로 보냅니다.항상_숨은참조규칙. 두번째AAFEF380C8D는 필터에 의해 번역되어(From 헤더를 그룹으로 변경) 에도 전송되지만 seccopies두 번 전송됩니다. 첫 번째 이메일에 이미 BCC가 있고 seccopies이제 Postfix는 BCC로 보내야 한다고 생각하기 때문 seccopies입니다 . 다시 얻습니다.

따라서 에 3개의 복사본을 가져와야 seccopies하지만2및 [3]은(는) 동일한 이메일(AAFEF380C8D):

  1. 첫 번째부터 >> Always_bcc y.hernandez까지y.hernandezseccopies
  2. 두 번째부터 informatics까지 y.hernandez>> Always_bccseccopies
  3. 세 번째는 >> Always_bcc (BCC로 informatics)seccopiesseccopies2)

원본의 단일 사본이 다음 주소로 전달됩니다 seccopies.

**DD925380C87**: to=<[email protected]>, relay=filter, delay=0.81, delays=0.11/0/0/0.7, dsn=2.0.0, status=sent (delivered via filter service)

의 라인은 uid=110어디입니까?2생성되고 두 개의 전달이 생성됩니다. 하나는 TO이고 y.hernandez다른 하나는 BCCd이므로 seccopies다음 행에 있습니다.

AAFEF380C8D: to=<[email protected]>, relay=dovecot, delay=1.1, delays=0.79/0/0/0.34, dsn=2.0.0, status=sent (delivered via dovecot service)
AAFEF380C8D: to=<[email protected]>, relay=dovecot, delay=1.1, delays=0.79/0/0/0.28, dsn=2.0.0, status=sent (delivered via dovecot service)

마지막으로 수정된 이메일이 의도한 수신자에게 전달됩니다.

AAFEF380C8D: to=<[email protected]>, relay=dovecot, delay=1.1, delays=0.79/0/0/0.35, dsn=2.0.0, status=sent (delivered via dovecot service)

중복 제거는 두 가지를 방지합니다.AAFEF380C8D이메일이 에 전달되지 않지만 seccopies그것이 중단될 것이라고는 생각하지 않습니다.DD925380C87이메일은 별도의 이메일이기 때문입니다.

따라가야 할 것 같아요이것지시, 그렇게콘텐츠 필터는 ... 자동 숨은 참조 결과 대신 원래 메일 주소를 봅니다., 그런 다음 이메일을 Postfix에 다시 삽입하고 Always_bcc를 적용합니다.

/etc/postfix/main.cf:
content_filter = scan:localhost:10025
receive_override_options = no_address_mappings

로부터receive_override_options: main.cf 파일에 "BEFORE 콘텐츠 필터" receive_override_options 설정이 지정된 경우 master.cf에 "AFTER 콘텐츠 필터" receive_override_options 설정을 지정합니다(또는 그 반대로).

관련 정보