
저는 최근 Postfix를 테스트하고 가상 환경에서 보내기 전용 메일 클라이언트로 구성했습니다. 작동할 때까지 여러 가상 머신의 설정을 가지고 놀다가 마침내 입력해야 할 적절한 값을 찾았습니다. 우리의 구성은 매우 기본적이므로 마스크 아웃하거나 도메인으로 설정하겠습니다. 아래 코드를 우리가 사용하는 것과 함께 사용하세요.
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
# Debian specific: Specifying a file name will cause the first
# line of that file to be used as the name. The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no
# appending .domain is the MUA's job.
append_dot_mydomain = no
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
readme_directory = no
# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = mail.example.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = mail.example, localhost.localdomain, localhost
relayhost = smtp-relay.gmail.com
mynetworks = 10.0.0.0/8 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
/etc/hostname의 내용은 다음과 같습니다.
mail.example.com
/etc/hosts의 내용은 다음과 같습니다.
127.0.0.1 localhost.localdomain localhost
10.x.x.x mail.example.com mail
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
아래의 /etc/mailname 내용
example.com
그러나 어떤 이유로든 이 구성은 이 파일과 일치하는 다른 서버와 동일하지만 명령줄에서 메일을 보냈을 때 다음과 같이 했습니다.
echo "testing email" | mail -s "test subject" [email protected]
한 서버는 그것이 어디에서 왔는지 보여줍니다.[이메일 보호됨], 다른 하나는 그 내용이 다음에서 유래했음을 보여줍니다.[이메일 보호됨].나는 평생 동안 그것을 알아낼 수 없으며, 이 두 서버 사이의 위치와 설정이 어떻게 다른지 잘 모르겠습니다(이후에도 서버를 재부팅하고 Postfix 서비스를 여러 번 다시 시작했습니다).
시스템 변수인 것 같거나 폴링되는 다른 구성 파일이 있는 것 같습니다. 저는 정말 궁금하고 여기서 무슨 일이 일어나고 있는지 이해하고 싶습니다. 어떤 정보라도 도움이 될 것입니다. 감사합니다!
업데이트 1: mail.log 비교 및 postconf -n 포함
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
config_directory = /etc/postfix
inet_interfaces = all
inet_protocols = all
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
mydestination = mail.example.com, localhost.localdomain, localhost
myhostname = mail.example.com
mynetworks = 10.0.0.0/8 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +
relayhost = smtp-relay.gmail.com
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes
Mail.log 비교
- 메일01:
uid=1000 from=<operations>
- 메일02:
uid=1000 [email protected]
- mail01의 메일은 사용자 이름(작업)만으로 제출되므로 postfix는 myorigin 만들기를 추가합니다.[이메일 보호됨].
- mail02의 메일은 전체 이메일 주소를 보낸 사람으로 제출한 것으로 보이므로 Postfix는 myorigin을 추가하지 않습니다.
둘 다 이를 위해 새로 생성되고 완전히 업데이트된 Ubuntu 14.04.3 VM에서 실행됩니다. 이 기본 사용자 이름이 구성된 위치는 어디에서 찾을 수 있나요? /etc/passwd를 확인했는데 "작업"이라고만 나와 있습니다. 어딘가에 누락된 파일이나 뭔가가 있는 것 같습니다. 어떤 아이디어가 있습니까?
답변1
나는 그것을 알아. 어떤 이유로든 내 /etc/mailname이 다른 서버와 동일하고 파일에 동일한 MD5sum이 있음에도 불구하고 처리되지 않은 것 같습니다. Postfix 구성이 이를 처리하지 못했습니다. 나는 또한 한 시스템(작동하지 않고 나중에 Postfix가 설치된 시스템)에서 mailutils를 사용하고 있고 다른 시스템은 bsd-mailx를 사용하고 있다는 것을 알아냈습니다. /etc/mailname 변경을 시도하기 전에 이것을 바꿨는데 별 차이가 없는 것 같았지만 가치가 있는 경우를 대비해 언급해 두었습니다. 어쨌든 내 /etc/mailname을 test와 같은 가짜 값으로 변경한 다음 sudo postfix reload 및 sudo service postfix restart를 수행한 다음 내가 의도한 대로(contoso.com) 다시 전환한 다음 동일한 두 명령을 수행했습니다. 구성과 서비스를 새로 고치고 보니 의도한 대로 작동하고 있었습니다. 도움을 주신 모든 분들께 감사드립니다.