Annexes:ConfPostfix : Différence entre versions

De WikiFr_dbSQWare
Aller à : navigation, rechercher
m (Tests et validation)
m (Ymauger a déplacé la page Annexes:ConfEnvoiMails vers Annexes:ConfPostfix)
(Aucune différence)

Version du 7 juin 2024 à 11:13

Ici nous vous proposerons deux approches de la configuration pour l'envoi de mails, si jamais vous avez vos méthodes ou habitudes en interne ne les changez pas.
Pour ces deux configurations utiliseront Postfix et Sendmail pour l'envoi de mails
'Site principal Postfix'.

Installation de Postfix et Sendmail

Cas de la machine dbSQWare

Si vous avez choisi d'utiliser la vmsqwarebox ou suivi notre guide d'installation d'un socle dbSQWare vous avez déjà les paquets installés. Une mise à jour suffira :

dbsqware@vmsqwarebox:/home/dbsqware $ sudo dnf update

Cas d'un serveur linux

D'un système linux à l'autre l'installation peut varier ici nous prenons une machine Rocky Linux 9

[admin@RockyLinux9 ~]#  sudo dnf update

[admin@RockyLinux9 ~]#  sudo dnf install postfix sendmail
Last metadata expiration check: 0:16:31 ago on Thu 06 Jun 2024 03:29:07 AM EDT.
Dependencies resolved.
===========================================================================================================================================================================================================
 Package                                        Architecture                                  Version                                               Repository                                        Size
===========================================================================================================================================================================================================
Installing:
 postfix                                          x86_64                                       2:3.5.9-24.el9                                        appstream                                       1.4 M
 sendmail                                         x86_64                                       8.16.1-11.el9                                         appstream                                       742 k
Installing dependencies:
 cyrus-sasl                                       x86_64                                       2.1.27-21.el9                                         baseos                                           71 k
 procmail                                         x86_64                                       3.22-56.el9                                           appstream                                       178 k
 tinycdb                                          x86_64                                       0.78-18.el9                                           appstream                                        33 k

Transaction Summary
===========================================================================================================================================================================================================
Install  5 Packages

Total download size: 2.4 M
Installed size: 6.6 M
Is this ok [y/N]:y
Downloading Packages:
(1/5): postfix-3.5.9-24.el9.x86_64.rpm                                                                                                                                     3.6 MB/s | 1.4 MB     00:00
(2/5): cyrus-sasl-2.1.27-21.el9.x86_64.rpm                                                                                                                                 180 kB/s |  71 kB     00:00
(3/5): tinycdb-0.78-18.el9.x86_64.rpm                                                                                                                                      144 kB/s |  33 kB     00:00
(4/5): procmail-3.22-56.el9.x86_64.rpm                                                                                                                                     143 kB/s | 178 kB     00:01
(5/5): sendmail-8.16.1-11.el9.x86_64.rpm                                                                                                                                   329 kB/s | 742 kB     00:02

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                      2.1 MB/s | 1.4 MB     00:00
[..]
Complete!

Cas d'un serveur Windows avec Cygwin


Attention.png
Warning:
Actuellement le paquet postfix pour Cygwin ne semble pas fonctionner..


Mise en place


Information.png
Information:
Nous ne traiterons que le cas d'envois de mails via une connexion authentifiée.


Approche 1


Note.png
Note:
Dans ce cas là chaque serveur se connecte à un relais externe.

Configuration générale de postfix

Variables à modifier dans main.cf :

[admin@RockyLinux9 ~]#  vi /etc/postfix/main.cf
...
myhostname = votre_hostname
mydomain = votre_domain.tld
relayhost  =   [votre.relais.externe]:numero_de_port

A ajouter à la fin du fichier :

# enable SASL authentication
smtp_sasl_auth_enable = yes
# disallow methods that allow anonymous authentication.
smtp_sasl_security_options = noanonymous
# where to find sasl_passwd
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
# Enable STARTTLS encryption
smtp_use_tls = yes

Si vous avez besoin de certificats, ajoutez également :

# where to find CA certificates
#smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt

Configurations supplémentaires

Il faut donner à postfix vos crédentials de connexions

[admin@RockyLinux9 ~]#  vi /etc/postfix/sasl_passwd
[votre.relais.externe] username:password

Il faut notifier postfix de cette nouvelle "route" de messagerie

postmap /etc/postfix/sasl_passwd

Approche 2


Information.png
Information:
Dans ce cas là ; la vmsqwarebox se connecte à un relais externe, les autres serveur utilisent la vmsqwarebox comme relayhost.


Configuration de la vmsqwarebox


Note.png
Note:
vous pouvez également réaliser cette configuration sur un autre serveur que la vmsqwarebox.


Configuration des clients du relais


Note.png
Note:
Si vous avez déjà un relayhost en interne appliquez également cette configuration à la vmsqwarebox.

Tests et validation

la commande -SenReport !

systemctl status postfix

dbsqware@vmsqwarebox:/etc/postfix $ sudo systemctl status postfix
● postfix.service - Postfix Mail Transport Agent
     Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; preset: disabled)
     Active: active (running) since Mon 2024-05-13 09:22:05 CEST; 3 weeks 3 days ago
    Process: 948 ExecStartPre=/usr/sbin/restorecon -R /var/spool/postfix/pid (code=exited, status=0/SUCCESS)
    Process: 957 ExecStartPre=/usr/libexec/postfix/aliasesdb (code=exited, status=0/SUCCESS)
    Process: 1047 ExecStartPre=/usr/libexec/postfix/chroot-update (code=exited, status=0/SUCCESS)
    Process: 1061 ExecStart=/usr/sbin/postfix start (code=exited, status=0/SUCCESS)
   Main PID: 1645 (master)
      Tasks: 9 (limit: 11099)
     Memory: 18.5M
        CPU: 59.255s
     CGroup: /system.slice/postfix.service
             ├─   1645 /usr/libexec/postfix/master -w
             ├─   1647 qmgr -l -t unix -u
             ├─  30563 tlsmgr -l -t unix -u
             ├─3202794 pickup -l -t unix -u
             ├─3209180 smtpd -n smtp -t inet -u -o stress=
             ├─3209181 proxymap -t unix -u
             ├─3209182 trivial-rewrite -n rewrite -t unix -u
             ├─3209183 cleanup -z -t unix -u
             └─3209184 smtp -t unix -u

Jun 06 08:55:49 vmsqwarebox postfix/smtp[3188686]: 57E1D82008C: to=<yohann.mauger@dbsqware.com>, relay=mail.gandi.net[217.70.178.9]:587, delay=0.49, delays=0.03/0.1/0.04/0.32, dsn=2.0.0, status=sent (25>
Jun 06 08:55:49 vmsqwarebox postfix/qmgr[1647]: 57E1D82008C: removed
Jun 06 11:36:27 vmsqwarebox postfix/smtpd[3209180]: connect from srvyohdbpg01.dbyoh.local[192.168.231.124]
Jun 06 11:36:27 vmsqwarebox postfix/smtpd[3209180]: 7584A82008C: client=srvyohdbpg01.dbyoh.local[192.168.231.124]
Jun 06 11:36:27 vmsqwarebox postfix/cleanup[3209183]: 7584A82008C: replace: header From: postgres@srvyohdbpg01 from srvyohdbpg01.dbyoh.local[192.168.231.124]; from=<sender@dbsqware.org> to=<yohann.mauge>
Jun 06 11:36:27 vmsqwarebox postfix/cleanup[3209183]: 7584A82008C: message-id=<20240606093708.C35531A06671@srvyohdbpg01.localdomain>
Jun 06 11:36:27 vmsqwarebox postfix/qmgr[1647]: 7584A82008C: from=<sender@dbsqware.org>, size=12419, nrcpt=1 (queue active)
Jun 06 11:36:27 vmsqwarebox postfix/smtpd[3209180]: disconnect from srvyohdbpg01.dbyoh.local[192.168.231.124] ehlo=2 starttls=1 mail=1 rcpt=1 data=1 quit=1 commands=7
Jun 06 11:36:27 vmsqwarebox postfix/smtp[3209184]: 7584A82008C: to=<yohann.mauger@dbsqware.com>, relay=mail.gandi.net[217.70.178.9]:587, delay=0.43, delays=0.02/0.11/0.04/0.26, dsn=2.0.0, status=sent (2>
Jun 06 11:36:27 vmsqwarebox postfix/qmgr[1647]: 7584A82008C: removed

dbsqware@vmsqwarebox:/etc/postfix $