smtp를 통해 접미사가 릴레이 될 때 발신 주소 강제 전용 사용자 계정을

AWS EC2 인스턴스에서 이메일 보고서를 가져 오려고합니다. 우리는 Exchange Online (Microsoft Online Services의 일부)을 사용하고 있습니다. SMTP 릴레이 전용 사용자 계정을 설정했으며이 서버를 통해 메시지를 릴레이하기위한 모든 요구 사항을 충족하도록 Postfix를 설정했습니다. 그러나 보낸 사람 주소가 인증 주소와 정확히 일치하지 않으면 Exchange Online의 SMTP 서버가 메시지를 거부합니다 (오류 메시지는 550 5.7.1 Client does not have permissions to send as this sender).

신중하게 구성하면이 사용자로 보내도록 서비스를 설정할 수 있습니다. 그러나 나는주의를 기울이는 열렬한 팬이 아닙니다. 나는 문제를 강제로 후시하고 싶습니다. 이것을 할 수있는 방법이 있습니까?



답변

이것이 실제로 접미사에서하는 방법입니다.

이 구성은 로컬에서 시작된 릴레이 및 릴레이 된 SMTP 메일 트래픽에서 보낸 사람 주소를 변경합니다.

/etc/postfix/main.cf :

sender_canonical_classes = envelope_sender, header_sender
sender_canonical_maps =  regexp:/etc/postfix/sender_canonical_maps
smtp_header_checks = regexp:/etc/postfix/header_check

서버 자체에서 보낸 전자 메일에서 봉투 주소를 다시 씁니다.

/ etc / postfix / sender_canonical_maps :

/.+/    newsender@address.com

SMTP 릴레이 전자 메일 주소에서 다시 쓰기

/ etc / postfix / header_check :

/From:.*/ REPLACE From: newsender@address.com

예를 들어 모든 다기능 및 여러 응용 프로그램에서 사용되는 로컬 릴레이 smtp 서버를 사용하는 경우 매우 유용합니다.

Office 365 SMTP 서버를 사용하는 경우 인증 된 사용자가 보낸 전자 메일과 다른 발신자 주소를 가진 메일은 거부됩니다. 위의 구성은 이것을 방지합니다.


답변

선택적인 일반 테이블은 메일이 서버에서 배달 될 때 적용되는 주소 매핑을 지정합니다.

이것은 서버에서 메일을받을 때 적용되는 정식 매핑 과 반대입니다 .

(참고 : 일반 및 표준 테이블을 대체하기 위해 FROM 및 TO 주소가 모두 일치합니다.)

서버 가 메일을 수신 할 때 표준 테이블을 사용하는 것은 이미 설명되어 있습니다.

를 사용하여 서버에서 메일을 보낼 때 FROM 주소를 다시 쓸 수 있습니다 smtp_generic_maps.

접미사 설명서 에 따르면 :

/etc/postfix/main.cf:
    smtp_generic_maps = hash:/etc/postfix/generic

/etc/postfix/generic:
    user@localdomain.local      account@isp.example.com
    @localdomain.local          wholedomain@isp.example.com

그런 다음 수행하십시오.

sudo postmap /etc/postfix/generic
sudo /etc/init.d/postfix reload

참고 문헌 :


답변

업데이트 : IT 친구의 조언에 따라 하나의 클라우드 메일 서버를 만드는 대신 모든 서버에서 postfix를 실행하고 있습니다. 지금까지 내 해결책은 다음과 같습니다.

/etc/postfix/main.cf

# output of hostname -f - mail from local users appears to come from here
myhostname = domU-01-02-03-04-05-06.compute-1.internal
# Local delivery - include all 127.0.0.1 aliases from /etc/hosts
mydestination = $myhostname, $mydomain, rest_of_entries_from_hosts
# Needed for address translation to work
myorigin = $mydomain

# Talking to MS Online
# :submission = port 587
relayhost = [smtp.mail.microsoftonline.com]:submission
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options =   # Yes, leave empty
smtp_tls_security_level = encrypt
smtp_generic_maps = hash:/etc/postfix/generic

# Enable if you need debugging, but it does leak credentials to the log
#debug_peer_level = 2
#debug_peer_list = smtp.mail.microsoftonline.com

# Only listen on the local interfaces (not the public)
inet_interfaces = localhost

# I left out a bunch of CentOS defaults.  postconf -n is your friend.
# These are included
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases

/etc/postfix/sasl_passwd

# Run postmap /etc/postfix/sasl_passwd after editing
# Also, chown root:root; chmod 600
smtp.mail.microsoftonline.com relayer@hosteddomain.com:YourP@ssw0rd

/etc/postfix/generic

# Run postmap /etc/postfix/generic
# I've seen local mail come from either source
# output of dnsdomainname
@compute-1.internal relayer@hosteddomain.com
# output of hostname -f
@domU-01-02-03-04-05-06.compute-1.internal relayer@hosteddomain.com

/etc/aliases

# Run newaliases after changing
# Lot of stuff here. Mostly, just make sure the graph points to root, such as
mailer-daemon:  postmaster
postmaster:     root

# And the important part - your email or distribution group
root:           awsadmins@hosteddomain.com

/etc/passwd

# Sometimes it helps to expand the name, so email comes from 'root at aws host 5'
#  rather than just 'root'
# Was
#root:x:0:0:root:/root:/bin/bash
# Is
root:x:0:0:root on aws host 5:/root:/bin/bash

내가 좋아하는 것 :

  • 많은 메일이 루트로 보내지고, 한 줄 alias은 누가 메일 을 받는지 알려줍니다.
  • 로컬 사용자의 모든 메일은에서 오는 것으로 변환 relayer@hosteddomain.com되므로 MS Online SMTP 서버를 통해 전달됩니다.
  • postfix는 sendmail보다 훨씬 나은 문서를 가지고 있습니다.

내가 싫어하는 것 :

  • 각 호스트 및 여러 단계에 대한 사용자 정의 변경이 필요합니다. 도움이되는 bash 스크립트를 작성했습니다.
  • passwd이름 트릭은 항상 일을하지 않는, 그리고 메일에서 오는 어떤 서버 파악하기가 어려울 수 있습니다.
  • 전송 된 모든 메일은 로그에 세 가지 경고를 표시합니다.
    1. warning: smtp.mail.microsoftonline.com[65.55.171.153] offered null AUTH mechanism list(SMTP 서버는 AUTH이전 STARTTLSAUTH LOGIN이후에 null 목록을 보냅니다 .)
    2. certificate verification failed for smtp.mail.microsoftonline.com: num=20:unable to get local issuer certificate (인증서에는 몇 가지 구성 옵션이 있지만 인증이 갱신 될 때 메일 배달이 중단되는지 확실하지 않습니다)
    3. certificate verification failed for smtp.mail.microsoftonline.com: num=27:certificate not trusted (# 2와 동일)

메일 서버에 대한 강력한 의견을 공유 한 serverfault 커뮤니티에 감사합니다.


답변

smtpd_sender_login_maps 를 사용하여 발신자 주소-사용자의 맵 목록을 지정할 수 있습니다 .

예:

smtpd_sender_login_maps =
    hash:/etc/postfix/login-map

/ etc / postfix / login-map :

mail1@domain    userlogin
mail2@domain    userlogin, otheruser@example.com

전송 작업과 같은 방식으로 릴레이 작업을 수행해야합니다.


답변

정규 매핑 을 사용 하여 root @ app01을 no-reply@example.com으로 다시 쓰는 것과 같은 보낸 사람 주소를 다시 씁니다.