FeaturesWP CloudPricingEE CLIContactMy Account
Features
Team Access & User Permissions
Install
Resources
Community
CLEAR
Tutorials
Emails
Postfix Queue Management
Topics
On this page
-
- Getting Started
- Git and File-System Layout (non-default setup)
- Version Constraints
- Managing Themes and Plugins (for entire WordPress site)
- Updating Themes and Plugins (for entire WordPress site)
- Adding Composer Support to Your Own Themes and Plugins (for developers)
- Using Composer to Manage Own Theme/Plugin Dependencies (for developers)
-
- Assigning Multiple IP Addresses to Single LAN Card
- Disable IPv6 on Ubuntu 12.04
- dsh – distributed shell
- fdupes – find & replace duplicate files with hardlinks
- GPG Keys Cheatsheet
- Increase "Open Files Limit"
- kill all php, nginx, mysql or any kind of processes
- Passwordless Authentication for SSH
- Screen
- search replace in multiple files useing grep xargs sed
- Setup sftp
- sysctl.conf
- Timezone Sync
- Using Google Public DNS on Ubuntu Server
- Using openssl to match private key, cerificate and CSR
- Configure Postfix to Use Gmail SMTP on Ubuntu
- Logrotate Example for Custom Logs
- PHP 5.5, MySQL, Postfix, Nginx and WordPress on Ubuntu
- Serverdensity
- Upgrade Ubuntu 10.04 to 12.04
- Using find and sed to replace strings in multiple files
- Webmin
-
- .my.cnf – mysql user & password
- Analyse slow-query-log using Anemometer
- Improving MySQL Query Cache
- MySQL Query Profiling
- Reset MySQL root password
- tuning-primer.sh – an alternative for mysqltuner
- Using MariaDB 10
- Install/Upgrade to MySQL 5.6 on Ubuntu 12.04 LTS
- Change WordPress Domain Name
- Character Sets and Collations
- Enable innodb_file_per_table
- Enable Remote Access (Grant)
- Installing Percona Toolkit
- Using tmpfs for temporary folder creation
- YARPP and InnoDB
- Convert MyISAM to InnoDB
- Using tmpfs for mysqldump & mysqlimport
- Convert from INNODB to MYISAM
- Analyse slow-query-log using mysqldumpslow & pt-query-digest
- mysqlcheck with cron to optimize automatically
- Using MySQLTuner to Optimize MySQL configuration
-
-
- Directly connect to PHP-FPM
- Generating core-dump for php5-fpm
- GeoIP
- Having php5 and php7 on same system.
- Install Xdebug and configure it with webgrind
- Installation of PHP Code Review Tools
- memcache
- PHP's Zend Opcache Config & Web Viewer
- Setting Sqlite support with PHP
- Using HHVM with PHP-FPM Fallback
- Using Redis for PHP Sessions on Ubuntu Server
- Installing PhpMyAdmin Quickly
- Moving PHP's session storage to tmpfs
- Install Xdebug and configure it with Netbeans
- Nginx – Enable PHP-FPM Status Page
- PHP-FPM: Socket vs TCP/IP and sysctl tweaking
- APC Cache Optimization & Monitoring Using Web Interface
- Checking if PHP/WordPress can send mails
- Debugging PHP Scripts Using slow_log and more
- Increase file upload size limit in PHP-Nginx
- Increase PHP script execution time with Nginx
-
- Performance Optimization
- Remove Query string of css/js files
- Setup ElasticSearch with ElasticPress
- Using Redis for WordPress Object-Cache
- WooCommerce Window Shopping Caching Technique
- Moving WordPress To New Server (Faster)
- Better wp-cron using linux's crontab
- 404 error- Page not Found!!!
- Debugging WordPress with Nginx
Status/Shape of Mail Queue
Dump entire mail queue
Read an email from mail queue
Attempt to send an email from mail queue
Attempt to send all email from mail queue
Deleting Pending mails from queue
Postfix Queue Management
Goal: To find which mails are stuck in mail queue and why?
If emails are getting delayed, its better to inspect postfix mail queues, coupled with postfix mail log.
Status/Shape of Mail Queue
Postfix maintains different queues for different purpose.active and deferred queues are of our interest.
Ideally, we should never have a mail in deferred queue.
qshape command will show shape of active mail queue by default. Ideally it should be as close as to empty since postfix sends email instantly!
qshape
Sample Outputs:
T 5 10 20 40 80 160 320 640 1280 1280+
TOTAL 0 0 0 0 0 0 0 0 0 0 0
If a mail is deferred, it will be moved to deferred queue.
Running following command will show you the number of deferred emails for each domains…
qshape deferred
Sample Output:
T 5 10 20 40 80 160 320 640 1280 1280+
TOTAL 5 0 0 0 0 0 0 0 0 0 5
gmail.com 4 0 0 0 0 0 0 0 0 0 4
yahoo.com 1 0 0 0 0 0 0 0 0 0 1
If you see mails to one or more domain only being deferred, check if you can connect to those servers from your network.
Analyze mails in queue
Dump entire mail queue
You can use either mailq or postqueue -pcommand. They will show an output like below:
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
2FC8824D24 10588 Thu Sep 27 14:52:41 from.me@example.com
(connect to alt2.gmail-smtp-in.l.google.com[74.125.79.26]:25: Connection timed out)
some.user@gmail.com
-- 16 Kbytes in 2 Requests.
You get dump for all emails from all mail queues including active & deferred queue.
Read an email from mail queue
Every message in queue has a unique id. You can read message in queue using a command like:
postcat -q DA80E24A0A
Or
postcat -qv DA80E24A0A
It will display your emails with headers and some more info. Using ‘v’ will display extra information.
Attempt to send an email from mail queue
Its better to first open postfix log using something like below:
tail -f /var/log/mail.{err,log}
Then you can identify a stuck mail and attempt to send it by using:
postqueue -i DA80E24A0A
If that mail gets stuck again, check log tab to find reason.
Once you fix issue, you can attempt to send that mail again. Mail ID inside queue remains same even if mail gets deferred again and again.
Attempt to send all email from mail queue
Once you rectify issue and confident about delivery, you may try flushing entire queue immediately using:
postqueue -f
Deleting Pending mails from queue
Sometimes you realize that all stuck emails are being sent to non-existent emails. Most likely emails generated because of some spam activity.
Delete All Deferred Mails
In that case, you can simply delete all queued mails using:
postsuper -d ALL deferred
Delete a single mail from queue
If you want to just delete one mail, you can try:
postsuper -d DA80E24A0A
Delete mails to a specific mail address
You need to some work here as postfix has no direct command for this.
Following sample is taken from postsuper man page:
mailq | tail -n +2 | grep -v '^ *(' | awk 'BEGIN { RS = "" } { if ($8 == "USER@EXAMPLE.COM" && $9 == "") print $1 } ' | tr -d '*!' | postsuper -d -
Just replace USER@EXAMPLE.COM with receiver email address.
$8 will contain recipient1 email-address, $9 will contain recipient2 email-address.
If you want to filter from-email address, use $7 variable.
Comments
-
manoj
Hi Rahul,
Thanks for help.. I am using UBUNTU 12 version and postfix mail. When i am sending any email from server.. it reach on SPAM box or junk box. For this, i have created reverse dns for my server and also create SPF record for particular domain. Can you please help me regarding this ?
Thanks & Regards,
Manoj Gupta
-
May be your server IP address is blacklisted. Check with External link to mxtoolbox.comhttp://mxtoolbox.com/blacklists.aspx
-
-
Excellent Boss…….
Features
- Server Setup & Management
- Site Creation & Management
- Create WP Cloud Sites
- Speed & Caching
- Firewall Protection
- Backups & Recovery
- Logs & Monitoring
- Deployments & Developer Tools
- Team Access & User Permissions
Useful Links
Product
Other Products
Subscribe for curated product updates, tips, and announcements.
"*" indicates required fields
X/Twitter
This field is for validation purposes and should be left unchanged.
Email*
SIGN ME UP
Δ
© rtCamp, since 2009. All rights reserved.