# Debian 10 / postfix multidomaine ==\> impossible d'envoyer à l'exterieur !

**URL:** <https://www.debian-fr.org/t/debian-10-postfix-multidomaine-impossible-denvoyer-a-lexterieur/79675>\
**Category:** Support Debian\
**Created:** [Juillet 18, 2019, 3:09 UTC](https://www.debian-fr.org/t/debian-10-postfix-multidomaine-impossible-denvoyer-a-lexterieur/79675 "2019-07-18T15:09:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jhfra](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/j/eb9ed0/32.png) [@jhfra](https://www.debian-fr.org/u/jhfra)\
**Post date:** [Juillet 18, 2019, 3:09 UTC](https://www.debian-fr.org/t/debian-10-postfix-multidomaine-impossible-denvoyer-a-lexterieur/79675/1 "2019-07-18T15:09:12Z")

</div>

Hello,

Voici mon problème : je suis en train de remonter une nouvelle infra, avec un serveur de mail et aujourd’hui je suis bloqué car l’envoi vers les domaines dont je n’ai pas la main (donc extérieur aux domaines que je gère) est impossible. De la même façon, si quelqu’un de l’extérieur envoie un mail sur l’un de ces domaines, on a la même erreur, qui est celle-ci :

```nohighlight
Diagnostic-Code: smtp; 550 5.1.0 <test@tartanpion.org>: Sender address rejected:
    User unknown in virtual mailbox table

```

**Ma compréhension du problème est que lorsque j’émets ou je reçois vers/de l’extérieur, mon serveur de mail cherche localement si le compte existe, ce qui forcément n’est pas le cas, par le fait il envoie aux pays des merveilles mon mail.**

Actuellement, ma configuration est “simple”, c’est à dire que j’ai Postfix configuré avec Dovecot, sur une base MySQL, et un peu de Sieve. La création des comptes/domaines mails se fait avec Postfixadmin et toute la partie DNS est déjà faite et normalement propre (j’ai un MX bien définit par domaine, avec une IP bien à lui). Rien d’extraordinaire, je n’ai pas attaqué l’antispam et l’antivirus.

Le domaine principal est **`tartanpion.org`** , le FQDN de ma machine correspond à un nom dont j’ai évidemment pleinement le contrôle sur mon serveur DNS, le reverse est bien entendu fonctionnel.

Mon **/etc/hosts** contient ceci :

```nohighlight
127.0.1.1 mail.tartanpion.org mail
127.0.0.1 localhost
1.2.3.4 ns1.tartanpion.org
1.2.4.5 ns2.tartanpion.org
1.2.6.7 mail.tartanpion.org mail
1.2.7.8 mail.tartanpion.ovh
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

```

mon **main.cf** :

```nohighlight
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
bounce_notice_recipient = monitoring@tartanpion.net
compatibility_level = 2
delay_notice_recipient = monitoring@tartanpion.net
delay_warning_time = 4h
disable_vrfy_command = yes
error_notice_recipient = monitoring@tartanpion.net
inet_interfaces = all
inet_protocols = ipv4
lmtp_tls_session_cache_database = btree:${data_directory}/lmtp_scache
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 1024000000
message_size_limit = 502400000
mydestination = $myhostname, mail, localhost.localdomain, localhost
mydomain = tartanpion.org
myhostname = mail.tartanpion.org
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = $myhostname
notify_classes = bounce, delay, resource, software
readme_directory = no
recipient_delimiter = +
relayhost =
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
smtp_tls_exclude_ciphers = aNULL, eNULL, EXPORT, DES, 3DES, RC2, RC4, MD5, PSK, SRP, DSS, AECDH, ADH
smtp_tls_loglevel = 1
smtp_tls_mandatory_ciphers = high
smtp_tls_mandatory_protocols = !SSLv2, !SSLv3
smtp_tls_note_starttls_offer = yes
smtp_tls_protocols = !SSLv2, !SSLv3
smtp_tls_security_level = may
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
smtpd_client_restrictions = permit_mynetworks, permit_sasl_authenticated, permit_inet_interfaces, reject_plaintext_session, reject_unauth_pipelining
smtpd_helo_required = yes
smtpd_helo_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_invalid_helo_hostname, reject_non_fqdn_helo_hostname, reject_unknown_helo_hostname
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_non_fqdn_recipient, reject_unauth_destination, reject_unknown_recipient_domain,
smtpd_sasl_auth_enable = yes
smtpd_sasl_authenticated_header = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_path = private/auth
smtpd_sasl_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_sender_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
smtpd_tls_CAfile = $smtp_tls_CAfile
smtpd_tls_auth_only = yes
smtpd_tls_cert_file = /etc/letsencrypt/live/cert_global_tartanpion/fullchain.pem
smtpd_tls_dh1024_param_file = $config_directory/dh4096.pem
smtpd_tls_dh512_param_file = $config_directory/dh512.pem
smtpd_tls_key_file = /etc/letsencrypt/live/cert_global_tartanpion/privkey.pem
smtpd_tls_loglevel = 1
smtpd_tls_mandatory_ciphers = medium
smtpd_tls_mandatory_protocols = !SSLv2, !SSLv3
smtpd_tls_protocols = !SSLv2, !SSLv3
smtpd_tls_received_header = yes
smtpd_tls_security_level = may
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes
tls_preempt_cipherlist = yes
tls_random_source = dev:/dev/urandom
virtual_alias_maps = mysql:/etc/postfix/mysql-virtual-alias-maps.cf
virtual_gid_maps = static:5000
virtual_mailbox_base = /var/mail
virtual_mailbox_domains = mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf
virtual_minimum_uid = 5000
virtual_transport = lmtp:unix:private/dovecot-lmtp
virtual_uid_maps = static:5000

```

mon **master.cf** :

```nohighlight
#
# Postfix master process configuration file. For details on the format
# of the file, see the master(5) manual page (command: "man 5 master" or
# on-line: http://www.postfix.org/master.5.html).
#
# Do not forget to execute "postfix reload" after editing this file.
#
# ==========================================================================
# service type private unpriv chroot wakeup maxproc command + args
# (yes) (yes) (no) (never) (100)
# ==========================================================================
smtp inet n - y - - smtpd
#smtp inet n - y - 1 postscreen
#smtpd pass - - y - - smtpd
#dnsblog unix - - y - 0 dnsblog
#tlsproxy unix - - y - 0 tlsproxy
submission inet n - y - - smtpd
  -o syslog_name=postfix/submission
  -o smtpd_tls_security_level=encrypt
# -o smtpd_sasl_auth_enable=yes
# -o smtpd_reject_unlisted_recipient=no
# -o smtpd_tls_dh1024_param_file=${config_directory}/dh4096.pem
# -o smtpd_client_restrictions=permit_sasl_authenticated,reject
# -o smtpd_helo_restrictions=$mua_helo_restrictions
# -o smtpd_sender_restrictions=$mua_sender_restrictions
# -o smtpd_recipient_restrictions=
# -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
# -o milter_macro_daemon_name=ORIGINATING
smtps inet n - y - - smtpd
  -o syslog_name=postfix/smtps
  -o smtpd_tls_wrappermode=yes
# -o smtpd_sasl_auth_enable=yes
# -o smtpd_reject_unlisted_recipient=no
# -o smtpd_client_restrictions=$mua_client_restrictions
# -o smtpd_helo_restrictions=$mua_helo_restrictions
# -o smtpd_sender_restrictions=$mua_sender_restrictions
# -o smtpd_recipient_restrictions=
# -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
# -o milter_macro_daemon_name=ORIGINATING
#628 inet n - y - - qmqpd
pickup unix n - y 60 1 pickup
cleanup unix n - y - 0 cleanup
qmgr unix n - n 300 1 qmgr
#qmgr unix n - n 300 1 oqmgr
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 smtp_helo_timeout=5 -o smtp_connect_timeout=5
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
#
# ====================================================================
# Interfaces to non-Postfix software. Be sure to examine the manual
# pages of the non-Postfix software to find out what options it wants.
#
# Many of the following services use the Postfix pipe(8) delivery
# agent. See the pipe(8) man page for information about ${recipient}
# and other message envelope options.
# ====================================================================
#
# maildrop. See the Postfix MAILDROP_README file for details.
# Also specify in main.cf: maildrop_destination_recipient_limit=1
#
maildrop unix - n n - - pipe
  flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
#
# ====================================================================
#
# Recent Cyrus versions can use the existing "lmtp" master.cf entry.
#
# Specify in cyrus.conf:
# lmtp cmd="lmtpd -a" listen="localhost:lmtp" proto=tcp4
#
# Specify in main.cf one or more of the following:
# mailbox_transport = lmtp:inet:localhost
# virtual_transport = lmtp:inet:localhost
#
# ====================================================================
#
# Cyrus 2.1.5 (Amos Gouaux)
# Also specify in main.cf: cyrus_destination_recipient_limit=1
#
#cyrus unix - n n - - pipe
# user=cyrus argv=/cyrus/bin/deliver -e -r ${sender} -m ${extension} ${user}
#
# ====================================================================
# Old example of delivery via Cyrus.
#
#old-cyrus unix - n n - - pipe
# flags=R user=cyrus argv=/cyrus/bin/deliver -e -m ${extension} ${user}
#
# ====================================================================
#
# See the Postfix UUCP_README file for configuration details.
#
uucp unix - n n - - pipe
  flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
#
# Other external delivery methods.
#
ifmail unix - n n - - pipe
  flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
bsmtp unix - n n - - pipe
  flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
scalemail-backend unix - n n - 2 pipe
  flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
mailman unix - n n - - pipe
  flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
  ${nexthop} ${user}

```

et ma conf **dovecot** :

```nohighlight
# 2.3.4.1 (f79e8e7e4): /etc/dovecot/dovecot.conf
# Pigeonhole version 0.5.4 ()
# OS: Linux 4.19.0-5-amd64 x86_64 Debian 10.0 ext4
# Hostname: mail.tartanpion.org
auth_mechanisms = plain login
first_valid_uid = 5000
imap_idle_notify_interval = 30 mins
last_valid_uid = 5000
listen = *
mail_gid = 5000
mail_location = maildir:/var/mail/vhosts/%d/%n/mail
mail_privileged_group = vmail
mail_uid = 5000
maildir_stat_dirs = yes
managesieve_notify_capability = mailto
managesieve_sieve_capability = fileinto reject envelope encoded-character vacation subaddress comparator-i;ascii-numeric relational regex imap4flags copy include variables body enotify environment mailbox date index ihave duplicate mime foreverypart extracttext
namespace inbox {
  inbox = yes
  location =
  mailbox Drafts {
    special_use = \Drafts
  }
  mailbox Junk {
    special_use = \Junk
  }
  mailbox Sent {
    special_use = \Sent
  }
  mailbox "Sent Messages" {
    special_use = \Sent
  }
  mailbox Trash {
    special_use = \Trash
  }
  prefix =
}
passdb {
  args = /etc/dovecot/dovecot-sql.conf.ext
  driver = sql
}
plugin {
  sieve = file:~/sieve;active=~/.dovecot.sieve
}
protocols = imap lmtp sieve
service auth-worker {
  user = vmail
}
service auth {
  unix_listener /var/spool/postfix/private/auth {
    group = postfix
    mode = 0666
    user = postfix
  }
  unix_listener auth-userdb {
    group = vmail
    mode = 0600
    user = vmail
  }
  user = dovecot
}
service imap-login {
  inet_listener imap {
    port = 143
  }
  inet_listener imaps {
    port = 993
    ssl = yes
  }
  service_count = 0
}
service lmtp {
  unix_listener /var/spool/postfix/private/dovecot-lmtp {
    group = postfix
    mode = 0600
    user = postfix
  }
}
service managesieve-login {
  inet_listener sieve {
    port = 4190
  }
  service_count = 1
}
ssl = required
ssl_cert = </etc/letsencrypt/live/cert_global_tartanpion/fullchain.pem
ssl_dh = # hidden, use -P to show it
ssl_key = # hidden, use -P to show it
userdb {
  args = uid=vmail gid=vmail home=/var/mail/vhosts/%d/%n
  driver = static
}
protocol lmtp {
  mail_plugins = quota sieve
  postmaster_address = postmaster@tartanpion.org
}
protocol imap {
  mail_max_userip_connections = 50
  mail_plugins = " imap_sieve"
  postmaster_address = postmaster@tartanpion.org
}

```

Côté test, pour la tentative de connexion, ça fonctionne plutôt bien :

```nohighlight
Connecting to 1.2.6.7

220 mail.tartanpion.org ESMTP Postfix (Debian/GNU) [707 ms]
EHLO keeper-us-east-1c.mxtoolbox.com
250-mail.tartanpion.org
250-PIPELINING
250-SIZE 502400000
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-DSN
250-SMTPUTF8
250 CHUNKING [684 ms]
MAIL FROM:<supertool@mxtoolbox.com>
250 2.1.0 Ok [708 ms]
RCPT TO:<test@mxtoolboxsmtpdiag.com>
450 4.7.1 Session encryption is required [693 ms]

LookupServer 3645ms

```

Et de manière plus globale, lorsque je passe un test sur  
`https://mxtoolbox.com/domain/tartanpion.org/`  
je n’ai pas le moindre warning ni erreur sur les 164 tests. Ça ne veut pas forcément dire que ma conf est parfaite, mais c’est un indicateur intéressant, dans la mesure où tout est dans les normes.

Pourriez-vous m’indiquer ce que je fais mal ? Pourquoi je n’arrive pas à émettre ou recevoir vers/depuis des domaines que je ne contrôle pas moi même ?

Par ailleurs, si vous avez des remarques (sans rapport avec ce problème précis), n’hésitez pas. Ce n’est que le 4eme que je monte intégralement et à chaque fois que je m’y prends différemment, les outils évoluant…

D’avance, mille mercis pour votre patience 🙂

---

<div class="post-metadata">

**Author:** ![PmGs](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/p/dfb087/32.png) [@PmGs](https://www.debian-fr.org/u/PmGs)\
**Post date:** [Juillet 18, 2019, 6:27 UTC](https://www.debian-fr.org/t/debian-10-postfix-multidomaine-impossible-denvoyer-a-lexterieur/79675/2 "2019-07-18T18:27:38Z")

</div>

Je commencerais à simplifier le main.cf, en commençant par les lignes …restrictions.  
Pour info dans mon zimbra ces lignes sont :  
\*smtpd\_recipient\_restrictions = reject\_non\_fqdn\_recipient, permit\_sasl\_authenticated, permit\_mynetworks, reject\_unlisted\_recipient, reject\_non\_fqdn\_sender, permit  
smtpd\_relay\_restrictions = permit\_sasl\_authenticated, permit\_mynetworks, reject\_unauth\_destination  
\*smtpd\_sender\_restrictions = check\_sender\_access regexp:/opt/zimbra/postfix/conf/tag\_as\_originating.re, permit\_mynetworks, permit\_sasl\_authenticated, permit\_tls\_clientcerts, check\_sender\_access hash:/opt/zimbra/conf/domainrestrict, check\_sender\_access regexp:/opt/zimbra/postfix/conf/tag\_as\_foreign.re

---

<div class="post-metadata">

**Author:** ![mattotop](https://www.debian-fr.org/user_avatar/www.debian-fr.org/mattotop/32/3942_2.png) [@mattotop](https://www.debian-fr.org/u/mattotop)\
**Post date:** [Juillet 18, 2019, 6:59 UTC](https://www.debian-fr.org/t/debian-10-postfix-multidomaine-impossible-denvoyer-a-lexterieur/79675/3 "2019-07-18T18:59:03Z")

</div>

> [@jhfra](#):
>
> ma conf **dovecot**

Alors sinon, juste ça, OSEF, ça ne concerne pas le SMTP, c’est à vérifier aprés, quand les mails sont tombés dans les boites.

> [@jhfra](#):
>
> ```auto
> Diagnostic-Code: smtp; 550 5.1.0 <test@tartanpion.org>: Sender address rejected:
> User unknown in virtual mailbox table
> 
> ```

Ca, ça veut dire ce que ça veut dire:  
que la recherche dans les tables virtuelles ou tu as défini tes domaines et tes users ne renvoie rien.

As tu vérifié la structure, et les données de tes tables sql ?

---

<div class="post-metadata">

**Author:** ![jhfra](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/j/eb9ed0/32.png) [@jhfra](https://www.debian-fr.org/u/jhfra)\
**Post date:** [Juillet 19, 2019, 8:28 UTC](https://www.debian-fr.org/t/debian-10-postfix-multidomaine-impossible-denvoyer-a-lexterieur/79675/4 "2019-07-19T08:28:33Z")

</div>

Hello,

Même en retirant tous les rejects, je ne reçois et n’émets rien vers l’extérieur.

@ [mattotop](https://www.debian-fr.org/u/mattotop) : Est-ce que ça répond à ta question ? Visiblement, côté structure tout a l’air bon :

```
.-(~)---------------------------------------------------------------------------------------------------------------------------------------------------------------------------(root@mail)-
`--# postmap -q tartanpion.com mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf
tartanpion.com
.-(~)---------------------------------------------------------------------------------------------------------------------------------------------------------------------------(root@mail)-
`--# postmap -q tartanpion.org mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf
tartanpion.org
.-(~)---------------------------------------------------------------------------------------------------------------------------------------------------------------------------(root@mail)-
`--# postmap -q admin@tartanpion.org mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf
tartanpion.org/admin/
.-(~)---------------------------------------------------------------------------------------------------------------------------------------------------------------------------(root@mail)-
`--# postmap -q test@tartanpion.org mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf
tartanpion.org/test/

```

Par ailleurs, je rappelle qu’en “interne”, c’est à dire sur les domaines que j’administre, j’arrive à envoyer des mails et à en recevoir. Ca ne fonctionne plus juste quand je reçois/envois de/vers l’extérieur.

merci

/edit: laissez tomber, je viens de comprendre…

Je faisais mes tests en destination de l’ancien (actuel) serveur de mail, celui qui hébergeait les même domaines. Et c’est lui qui répondait encore pour les domaines que j’hébergeais autrefois, donc forcément il cherchait l’existence de comptes que j’ai créé sur le nouveau serveur et qui n’exist pas sur l’ancien.  
Mea culpa… en essayant avec des domaines sans rapport, par exemple gmail ou free, ça fonctionne.

Merci toutefois de votre aide.
