Você pode usar reject_authenticated_sender_login_mismatch
Fazer usuários para teste
# saslpasswd2 -c -u example.net user1
# saslpasswd2 -c -u example.com user2
# sasldblistusers2
[email protected]: userPassword
[email protected]: userPassword
Faça alguns testes básicos. Como você pode ver sem reject_authenticated_sender_login_mismatch, o usuário pode usar em MAIL FROM o que ele quiser
# echo "Hello world" | swaks -s 127.0.0.1 --from [email protected] --to [email protected] --h-Subject "Test" --auth PLAIN --auth-user user1 --auth-password 1234567 --body -
=== Trying 127.0.0.1:25...
=== Connected to 127.0.0.1.
<- 220 mail.example.net ESMTP Postfix
-> EHLO svn.example.net
<- 250-mail.example.net
<- 250-PIPELINING
<- 250-SIZE 10240000
<- 250-VRFY
<- 250-ETRN
<- 250-AUTH LOGIN PLAIN
<- 250-ENHANCEDSTATUSCODES
<- 250-8BITMIME
<- 250 DSN
-> AUTH PLAIN AHVzZXIxADEyMzQ1Njc=
<- 235 2.7.0 Authentication successful
-> MAIL FROM:<[email protected]>
<- 250 2.1.0 Ok
-> RCPT TO:<[email protected]>
<- 250 2.1.5 Ok
-> DATA
<- 354 End data with <CR><LF>.<CR><LF>
-> Date: Thu, 25 Feb 2016 20:53:45 +0000
-> To: [email protected]
-> From: [email protected]
-> Subject: Test
-> X-Mailer: swaks v20130209.0 jetmore.org/john/code/swaks/
->
-> Hello world
->
->
-> .
<- 250 2.0.0 Ok: queued as E1D3D406CC
-> QUIT
<- 221 2.0.0 Bye
=== Connection closed with remote host.
# grep E1D3D406CC /var/log/maillog
Feb 25 20:53:45 svn postfix/smtpd[56996]: E1D3D406CC: client=localhost[127.0.0.1], sasl_method=PLAIN, [email protected]
Feb 25 20:53:45 svn postfix/cleanup[56999]: E1D3D406CC: message-id=<[email protected]>
Feb 25 20:53:45 svn postfix/qmgr[56990]: E1D3D406CC: from=<[email protected]>, size=416, nrcpt=1 (queue active)
Feb 25 20:53:45 svn postfix/local[57000]: E1D3D406CC: to=<[email protected]>, relay=local, delay=0.03, delays=0.02/0/0/0.01, dsn=2.0.0, status=sent (delivered to mailbox)
Feb 25 20:53:45 svn postfix/qmgr[56990]: E1D3D406CC: removed
# echo "Hello world" | swaks -s 127.0.0.1 --from [email protected] --to [email protected] --h-Subject "Test" --auth PLAIN --auth-user user1 --auth-password 1234567 --body -
=== Trying 127.0.0.1:25...
=== Connected to 127.0.0.1.
<- 220 mail.example.net ESMTP Postfix
-> EHLO svn.example.net
<- 250-mail.example.net
<- 250-PIPELINING
<- 250-SIZE 10240000
<- 250-VRFY
<- 250-ETRN
<- 250-AUTH LOGIN PLAIN
<- 250-ENHANCEDSTATUSCODES
<- 250-8BITMIME
<- 250 DSN
-> AUTH PLAIN AHVzZXIxADEyMzQ1Njc=
<- 235 2.7.0 Authentication successful
-> MAIL FROM:<[email protected]>
<- 250 2.1.0 Ok
-> RCPT TO:<[email protected]>
<- 250 2.1.5 Ok
-> DATA
<- 354 End data with <CR><LF>.<CR><LF>
-> Date: Thu, 25 Feb 2016 20:55:13 +0000
-> To: [email protected]
-> From: [email protected]
-> Subject: Test
-> X-Mailer: swaks v20130209.0 jetmore.org/john/code/swaks/
->
-> Hello world
->
->
-> .
<- 250 2.0.0 Ok: queued as 94CBF4076C
-> QUIT
<- 221 2.0.0 Bye
=== Connection closed with remote host.
# grep 94CBF4076C /var/log/maillog
Feb 25 20:55:13 svn postfix/smtpd[56996]: 94CBF4076C: client=localhost[127.0.0.1], sasl_method=PLAIN, [email protected]
Feb 25 20:55:13 svn postfix/cleanup[56999]: 94CBF4076C: message-id=<[email protected]>
Feb 25 20:55:13 svn postfix/qmgr[56990]: 94CBF4076C: from=<[email protected]>, size=424, nrcpt=1 (queue active)
Feb 25 20:55:13 svn postfix/local[57000]: 94CBF4076C: to=<[email protected]>, relay=local, delay=0.01, delays=0.01/0/0/0, dsn=2.0.0, status=sent (delivered to mailbox)
Feb 25 20:55:13 svn postfix/qmgr[56990]: 94CBF4076C: removed
Mas depois de adicionar as seguintes linhas
# /etc/postfix/main.cf
smtpd_sender_login_maps = hash:/etc/postfix/sender_logins_maps
smtpd_sender_restrictions = reject_authenticated_sender_login_mismatch
Não se esqueça de criar um mapa e reiniciar o postfix
# postmap /etc/postfix/sender_logins_maps
# service postfix restart
# cat /etc/postfix/sender_logins_maps
[email protected] [email protected]
[email protected] [email protected]
[email protected] [email protected]
O usuário não pode mais usar o que quiser
# echo "Hello world" | swaks -s 127.0.0.1 --from [email protected] --to [email protected] --h-Subject "Test" --auth PLAIN --auth-user user1 --auth-password 1234567 --body -
=== Trying 127.0.0.1:25...
=== Connected to 127.0.0.1.
<- 220 mail.example.net ESMTP Postfix
-> EHLO svn.example.net
<- 250-mail.example.net
<- 250-PIPELINING
<- 250-SIZE 10240000
<- 250-VRFY
<- 250-ETRN
<- 250-AUTH LOGIN PLAIN
<- 250-ENHANCEDSTATUSCODES
<- 250-8BITMIME
<- 250 DSN
-> AUTH PLAIN AHVzZXIxADEyMzQ1Njc=
<- 235 2.7.0 Authentication successful
-> MAIL FROM:<[email protected]>
<- 250 2.1.0 Ok
-> RCPT TO:<[email protected]>
<** 553 5.7.1 <[email protected]>: Sender address rejected: not owned by user user1
-> QUIT
<- 221 2.0.0 Bye
=== Connection closed with remote host.
Mas com as configurações acima, [email protected] pode usar somente em MAIL FROM: [email protected], [email protected] e [email protected]
# echo "Hello world" | swaks -s 127.0.0.1 --from [email protected] --to [email protected] --h-Subject "Test" --auth PLAIN --auth-user [email protected] --auth-password 1234567 --body -
=== Trying 127.0.0.1:25...
=== Connected to 127.0.0.1.
<- 220 mail.example.net ESMTP Postfix
-> EHLO svn.example.net
<- 250-mail.example.net
<- 250-PIPELINING
<- 250-SIZE 10240000
<- 250-VRFY
<- 250-ETRN
<- 250-AUTH LOGIN PLAIN
<- 250-ENHANCEDSTATUSCODES
<- 250-8BITMIME
<- 250 DSN
-> AUTH PLAIN AHVzZXIxQGV4YW1wbGUubmV0ADEyMzQ1Njc=
<- 235 2.7.0 Authentication successful
-> MAIL FROM:<[email protected]>
<- 250 2.1.0 Ok
-> RCPT TO:<[email protected]>
<- 250 2.1.5 Ok
-> DATA
<- 354 End data with <CR><LF>.<CR><LF>
-> Date: Thu, 25 Feb 2016 23:03:07 +0000
-> To: [email protected]
-> From: [email protected]
-> Subject: Test
-> X-Mailer: swaks v20130209.0 jetmore.org/john/code/swaks/
->
-> Hello world
->
->
-> .
<- 250 2.0.0 Ok: queued as 9FE524068A
-> QUIT
<- 221 2.0.0 Bye
=== Connection closed with remote host.
# grep 9FE524068A /var/log/maillog
Feb 25 23:03:07 svn postfix/smtpd[19097]: 9FE524068A: client=localhost[127.0.0.1], sasl_method=PLAIN, [email protected]
Feb 25 23:03:07 svn postfix/cleanup[19100]: 9FE524068A: message-id=<[email protected]>
Feb 25 23:03:07 svn postfix/qmgr[19092]: 9FE524068A: from=<[email protected]>, size=419, nrcpt=1 (queue active)
Feb 25 23:03:07 svn postfix/local[19101]: 9FE524068A: to=<[email protected]>, relay=local, delay=0.01, delays=0.01/0/0/0, dsn=2.0.0, status=sent (delivered to mailbox)
Feb 25 23:03:07 svn postfix/qmgr[19092]: 9FE524068A: removed
P.S. um pequeno truque
se você não adicionar nenhuma linha para algum usuário específico no /etc/postfix/sender_logins_maps - ele receberá e-mails, mas não enviará.
I can't seem to run saslauthd. It says command not found. Is that a separate utility? EDIT: Sorry I meant to say testsaslauthd. Neither work
É apenas um teste. Então, para o ambiente de teste de configuração rápida eu escolhi o sasldb. Porque eu não tenho tempo para configurar e configurar o MySQL. Você está usando o MySQL para armazenar todas as informações sobre usuários. E suas restrições descritas aqui
smtpd_sender_login_maps =
proxy:mysql:/etc/postfix/sql/mysql_virtual_sender_acl.cf
proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_maps.cf
Você deve adicionar o conteúdo do mysql_virtual_sender_acl.cf/mysql_virtual_alias_maps.cf (sem senha, é claro) à pergunta
Is there a way to configure Postfix to allow me to send from any address on this one particular domain after authenticating with one account?
no / etc / postfix / sender_logins_maps você deve ter algo como o seguinte
@example.net [email protected]
Modifique smtpd_sender_login_maps
smtpd_sender_login_maps =
hash:/etc/postfix/sender_logins_maps,
proxy:mysql:/etc/postfix/sql/mysql_virtual_sender_acl.cf,
proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_maps.cf
O arquivo / etc / postfix / sender_logins_maps deve conter apenas uma linha
@example.net [email protected]
onde @ example.net - "um domínio em particular", [email protected] - "autenticação com uma conta". Deve ser sasl_username!
sasl_method=PLAIN, [email protected]
Não se esqueça de criar um mapa e reiniciar o postfix.