Proxmox Postfix Configuration
1
2
Configuring Postfix on Proxmox allows you to send email notifications for system events, backups, and other alerts. Below are the steps to set up Postfix for external email relaying.
Step 1: Update Postfix Configuration
Edit the Postfix configuration file /etc/postfix/main.cf to include the following lines:
relayhost = [smtp.gmail.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
Copy
Replace smtp.gmail.com with your SMTP server (e.g., for Gmail, Outlook, etc.).
Step 2: Create Authentication File
Create the file /etc/postfix/sasl_passwd with your SMTP credentials:
[smtp.gmail.com]:587 your_email@gmail.com:your_password
Copy
Replace your_email@gmail.com and your_password with your actual email and password.
Secure the file:
chmod 600 /etc/postfix/sasl_passwd
postmap /etc/postfix/sasl_passwd
Copy
Step 3: Install Required Packages
Ensure SASL modules are installed:
apt-get install libsasl2-modules
Copy
Step 4: Restart Postfix
Restart the Postfix service to apply changes:
systemctl restart postfix.service
Copy
Step 5: Test Email Sending
Send a test email to verify the configuration:
echo "Test mail from postfix" | mail -s "Test Postfix" recipient@example.com
Copy
Check logs for errors if the email fails:
tail -f /var/log/mail.log
Copy
Optional: Customize Email Headers
To change the "From" address, create /etc/postfix/smtp_header_checks:
/^From:.*/ REPLACE From: Proxmox-Alert <alerts@yourdomain.com>
Copy
Add this line to main.cf:
smtp_header_checks = pcre:/etc/postfix/smtp_header_checks
Copy
Run:
postmap /etc/postfix/smtp_header_checks
systemctl restart postfix.service