send email from proxmox from terminal (without installing additional mail client)

In fact it does work for me...
Code:
bash -x g
+ FROM=pve@blockbridge.com
+ TO=xxxx@blockbridge.com
+ SUBJECT='Test Email'
+ BODY='This is a test email from Proxmox terminal.'
+ echo 'From: pve@blockbridge.com'
+ echo 'To: xxxx@blockbridge.com'
+ echo 'Subject: Test Email'
+ echo
+ echo 'This is a test email from Proxmox terminal.'
+ sendmail -t

Code:
from:    pve@blockbridge.com
to:    xxxx@blockbridge.com
date:    Oct 22, 2025, 11:30 AM
subject:    Test Email
:    Important according to Google magic.



Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
After reading this post I think one needs to install postfix: https://forum.proxmox.com/threads/use-smtp-to-send-all-notifications.142573/

I followed the steps described here:


Code:
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
 
Last edited:
  • Like
Reactions: Johannes S