FeaturesWP CloudPricingEE CLIContactMy Account
Features
Team Access & User Permissions
Install
Resources
Community
CLEAR
Tutorials
Emails
Debugging Postfix Config, Mail Logs & more
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
Check if postfix can send emails
Postfix configuration
Reconfigure postfix
Hostname
Check postfix mail logs
Checking postfix queue
Debugging Postfix Config, Mail Logs & more
Note: Please check common mistakes with mail server first.
You will need to debug postfix, when you are facing email related issues like emails are not sent, emails are delivered but with a long delay, mail bounces, etc.
In this article, we will first see how we can check if postfix itself can send emails. Then we will see postfix configuration/re-configuration and some related parameter. It will be followed by checking postfix mail logs for errors and finally inspecting mail queues to diagnose different postfix related problems.
Check if postfix can send emails
If your WordPress or PHP or any other application is not able to send emails, first thing you should check if postfix can send emails itself.
echo "Test mail from postfix" | mail -s "Test Postfix" admin@something.com
Please replace admin@something.com. Its better to run a test with your free email id with gmail, yahoo, etc first. If you can receive test mail sent above then that means postfix is able to send emails.
If postfix fails to send emails, its better to check if PHP/WordPress can send email as well.
Postfix configuration
You can run command postconf -n and it will show postfix config in action! This is very convenient as reading config files with lots of comments can get tiring sometimes. Though you can skip commented part using this also, postconf -n is quite handy and useful.
It’s sample output consist lines like below:
mydestination = $myorigin, localhost.rtcamp.com, localhost
myhostname = $myorigin
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
I have skipped other lines because most issues are related to above lines (in my experience).
If you see anything wrong, you can fix it up by editing /etc/postfix/main.cf file. If you make any changes to postfix config, don’t forget to reload it by running command: /etc/init.d/postfix reload
Reconfigure postfix
On Ubuntu/Debian, you can run command dpkg-reconfigure postfix .
It will start an interactive wizard which will guide you through different configurations.
Hostname
One important config value is hostname of your system. To check it, run hostname command. It should show a domain you like to use to send mails from. If you want to change it, you better change /etc/hostname file. It just contains one line.
Its also recommended to add a line like below in your /etc/host file
127.0.0.1 host1.example.com host1
For better email delivery, you must create “A record” on DNS for example.com pointing to public IP of your machine hosting host1.example.com.
Check postfix mail logs
When you run into postfix or email issues, first thing, you should check is postfix mail logs which are present in /var/log/mail.log file.
It contains postfix’s general logs. Keeping tail -f /var/log/mail.log running in a separate terminal window will be helpful.
If you can see a file /var/log/mail.err then its better to check it first. mail.err is only for “error” logging.
There are many kind of error messages possible. Not all are added by postfix! Some other applications like dovecot, cyrus, etc also make use of these log files. Its better to Google first as solutions for most of common errors are already present out there.
Read this if you want to get more detailed postfix logs.
Checking postfix queue
This is covered in details here – http://rtcamp.com/tutorials/mail/postfix-queue/
Using larch for mail transfer between imap/gmail servers
PREVIOUS
Increasing Attachment Size in Posfix
NEXT
Comments
-
Mark
The ‘mail’ command no longer works in 12.10
-
Try installing mailutils package:
apt-get install mailutils-
Mark
Got it working with sudo apt-get install bsd-mailx
Just noting as the original command won’t work on a default install
-
Thanks for update 🙂
-
-
-
-
manoj
Hi,
I am using postfix on centos 6.4. Now there are lotsof mails in mailq. When i checked email, i show there are lots of email from —-@mail.ru. I don’t know about this email domain. Can you please suggest me that how to remove all mail from mailq, which is associated with ……..@mail.ru.
Thanks & Regards.
MG-
Sorry for delayed reply.
I have covered debugging postfix queue in a seprate post – External link to rtcamp.comhttp://rtcamp.com/tutorials/mail/postfix-queue/
Please check that.
-
-
ihsan
hi Rahul ,
you are doing nice work and very eassy to understand for dump like me in Linux 🙂
i recently configure one Mail Gateway for our Hosted Exchange from some tutorial but it seems the PostFix and mailscanner not working . following is output of postconf -n which i learn from you 🙂 thanks
in output online 12 it show error on localtransport .
exit ();
[root@MAIL-SVR05 ~]# postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
header_checks = regexp:/etc/postfix/header_checks
html_directory = no
inet_interfaces = localhost
inet_protocols = all
local_transport = error:local mail delivery is disabled
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
message_size_limit = 10240000
mydestination = local_recipient_maps =
mydomain = MAIL-SVR05.amgexc.com
mynetworks = 37.220.204.128/28, 255.255.255.240
myorigin = MAIL-SVR05.xyz.com
newaliases_path = /usr/bin/newaliases.postfix
parent_domain_matches_subdomains = debug_peer_list, smtp_access_maps
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
relay_domains = amanatelecom.com,amanagroup.co.uk,cloud-coms.co.uk
sample_directory = /usr/share/doc/postfix-2.6.6/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
show_user_unknown_table_name = no
smtpd_recipient_restrictions = permit_mynetworks, reject_unauth_destination, check_policy_service unix :postgrey/socket, permit
transport_maps = hash:/etc/postfix/transport
unknown_local_recipient_reject_code = 550
virtual_alias_maps = hash:etc/postfix/virtuali dont understand how to resolve this error . your help will surly save my life 🙂 thanks in advance
Note : i was not able to send mail from Postfix in Centos was relpyng no mail command found also try to install apt-get install mailutils . 🙁 no luck-
Please try mail server setup guide I posted here – External link to rtcamp.comhttp://rtcamp.com/tutorials/mail/server/
I am sorry but I won’t be able to offer support for other tutorials. Plus we do not support Centos. It you can use only Centos, it will be better to use Centos or postfix support forum.
-
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
Name
This field is for validation purposes and should be left unchanged.
Email*
SIGN ME UP
Δ
© rtCamp, since 2009. All rights reserved.