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

  1. To see which emails are being tried to send via Postfix:
  2. # journalctl -u postfix -f
  3. or
  4. # tail -f /var/log/mail.log

Check the Configuration

  1. To check the syntax of the Postfix configuration file:
  2. # postfix check
  3. If you need to review the configuration, this command shows only the used parameters:
  4. # postconf -n

Show the Mail Queue

  1. # mailq
  2. or
  3. # postqueue -p

Flush the Mail Queue

During testing, emails may remain stuck in the queue because of incorrect relay parameters or temporary connectivity issues.

  1. To retry delivery of queued emails:
  2. # postqueue -f

Delete the Mail Queue

  1. To delete all queued emails:
  2. # postsuper -d ALL
  3. To delete a specific queued email with ID:
  4. # postsuper -d QUEUE_ID