[SOLVED] Email reporting (Proxmox VE 7.2)

Feb 4, 2021
10
5
23
51
Hi everyone,

I installed a new Proxmox.
But I can't send email reporting.
The recipient address is hosted by office365.

So, when i try :
mail -s "Test" <my Office365 email>

Nothing happens.
And in /var/log/mail.log :
AC31E180EAA: to=<my Office365 email>, relay=none, delay=80026, delays=79966/0.03/60/0, dsn=4.4.1, status=deferred (connect to <my Office365 domain>.mail.protection.outlook.com[104.47.24.36]:25: Connection timed out)

And here is my /etc/postfix/main.cf
# See /usr/share/postfix/main.cf.dist for a commented, more complete version myhostname=srvpra02.clgstpaul.com smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU) 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 alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases mydestination = $myhostname, localhost.$mydomain, localhost relayhost = mynetworks = 127.0.0.0/8 inet_interfaces = loopback-only recipient_delimiter = + compatibility_level = 2


Any idea ?

Regards
 
Thanks for the help, it works !

So I put the actions/commands bellow for Microsoft 365:

Modify the file /etc/postfix/main.cfg. Adding the lines
relayhost = [smtp.office365.com]:587 smtp_use_tls = yes smtp_sasl_auth_enable = yes smtp_sasl_security_options = noanonymous smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt

In the same file, if exist, comment the lines
smtp_sasl_security_options = {} and relayhost = {}


Create the file /etc/postfix/sasl_passwd
And add the following :
[smtp.office365.com]:587 emailaddressforproxmox:password of the email

Change the rights on the file :
chmod 600 /etc/postfix/sasl_passwd postmap /etc/postfix/sasl_passwd

Install librairies for sasl_passwd
apt install libsasl2-modules

It could be necessary to rewrite the headers :
Create the file /etc/postfix/smtp_header_checks
And add the following :
^From:.*/ REPLACE From: HOSTNAME-alert <emailaddressforproxmox>

Modify the file /etc/postfix/main.cfg. Adding the lines :
smtp_header_checks = pcre:/etc/postfix/smtp_header_checks

Change the rights on the file :
chmod 600 /etc/postfix/smtp_header_checks postmap /etc/postfix/smtp_header_checks

Install PCRE :
apt install postfix-pcre

Restart Postfix :
systemctl restart postfix.service

Test :
echo "Test mail from postfix" | mail -s "Test Postfix" recipientaddress@office365.com