Testing and Debugging Postfix
Sending a Test Email via the Internal Mail Relay
Sending a Test Email via PowerShell
You can use PowerShell to send a test email through the Internal relay.
Note:
Ensure that you change the IP address and email addresses.
Send-MailMessage `
-SmtpServer "10.0.1.129" `
-Port 25 `
-From "smtprelaytest@customerdomain.com" `
-To "mail@domain.com" `
-Subject "SMTP relay test mail" `
-Body "This is SMTP unencrypted"
Sending a Test Email via curl
For more detailed debugging information, use curl because it prints much more debugging information.
curl --url "smtp://10.0.1.129:25" ^
--mail-from "smtprelay@customerdomain.com" ^
--mail-rcpt "test@recipient.com" ^
--upload-file mail.txt ^
-v
mail.txt:
From: smtprelay@customerdomain.com
To: test@recipient.com
Subject: SMTP Relay Test
This mail has been sent via mail relay
Ensure that the recipient address in mail.txt matches the address specified in the --mail-rcpt parameter. Otherwise, delivery may fail.
Debugging Postfix
View Mail Logs
- To see which emails are being tried to send via Postfix:
# journalctl -u postfix -f- or
# tail -f /var/log/mail.log
Check the Configuration
- To check the syntax of the Postfix configuration file:
# postfix check- If you need to review the configuration, this command shows only the used parameters:
# postconf -n
Show the Mail Queue
# mailq- or
# postqueue -p
Flush the Mail Queue
During testing, emails may remain stuck in the queue because of incorrect relay parameters or temporary connectivity issues.
- To retry delivery of queued emails:
# postqueue -f
Delete the Mail Queue
- To delete all queued emails:
# postsuper -d ALL- To delete a specific queued email with ID:
# postsuper -d QUEUE_ID