FeaturesWP CloudPricingEE CLIContactMy Account
Features
Team Access & User Permissions
Install
Resources
Community
CLEAR
Tutorials
PHP
Checking if PHP/WordPress can send mails
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
First check if PHP-scripts can send emails
Check if WordPress can send emails
Checking if PHP/WordPress can send mails
WordPress has grown from a blogging platform to become a highly efficient CMS. Chances are high that you are using a contact form on your WordPress. Imagine if a prospective client fills up your contact form but WordPress fails to send you an email notification!
If you are facing problems like these, you should do the following:
First check if PHP-scripts can send emails
php -a
mail ('you@example.com', "Test Postfix", "Test mail from postfix");
exit ();
Note: if after running php -a, you get "Interactive mode enabled" message but no php> prompt, then your PHP is not compiled with readline support. If its working nice, you will get only "Interactive mode" message with php> prompt.
You can still run test though. Just create a testmail.php with following lines of codes:
<?php
mail ('you@example.com', "Test Postfix", "Test mail from postfix");
?>
and run it on your server with php -f testmail.php command. If you can’t see any email form PHP, then that means its PHP’s fault.
Check value of sendmail_path in php.ini config. If its wrong, fix it and run above test again.
If PHP can send mails, but WordPress cannot, its better to test WordPress.
Check if WordPress can send emails
Testing WordPress is easy. You can do it using this plugin. I know that plugin is not updated from 2 years but I tested it with WordPress 3.4 without any issue. Its a simple plugin so chances are very less that it will break in future as well! 😉
Now if in your test you can send emails but still facing issues with contact form, its better to check your plugins then. Mostly likely it will be some coding issue.
APC Cache Optimization & Monitoring Using Web Interface
PREVIOUS
Debugging PHP Scripts Using slow_log and more
NEXT
Comments
-
Hello!
What is sendmail_path in php.ini?
Thank you!
-
Its a path to sendmail program on your server.
On Linux, just run command:
which sendmailIt will show you path like:
/usr/sbin/sendmailIn my case, value of “sendmail_path” is “/usr/sbin/sendmail -t -i -f www@my.domain.com“. This is system default as I never needed to change it.
-
-
KardiWeb
I’m doing all of this assistance. does not work :/
-
Sorry but I couldn’t understood what you wanted to say.
Please ask your question more clearly (may be with some details).
-
-
Thanks for your guides
Im in the process of setting my own ubuntu box up with WordPress and postfix.
It sends okay with the command
echo "Test from Postfix" | mail -s "Test" test@domain.comIt also sends okay via the php commands you mentioned above. However it doesnt send via wordpress. Using the plugin it goes but never gets delivered. mail.log shows no entry.
Any ideas where to look?
-
Please check
error.logfile for WordPress. Most likely it will be available at/var/www/domain.com/logs/error.log.Also, you can disable other WordPress plugins and check if WordPress can send emails.
-
-
Thanks. I found the issue in the end. In the apache logs it was pointing to the wrong path for sendmail. Was missing the / before /usr/
-
@Dale
Glad to know that your issue got fixed. 🙂
-
ken
I can send and receive the email using echo “Test from Postfix” | mail -s “Test” test@domain.com but when I tried using “check email” plugin in WordPress, it didn’t work.
-
@Ken
Sorry for delayed reply. If you are facing issues as of now, please send error logs.
-
-
-
Andree
Jul 22 16:56:12 smith postfix/error[19857]: BC723A061: to=, relay=none, delay=0.01, delays=0/0/0/0, dsn=5.0.0, status=bounced (gmx.de)
POSTFIX
# postconf -d | grep mail_version
mail_version = 2.7.1
milter_macro_v = $mail_name $mail_version-
@Andree
I did not get what you are trying to ask?
-
-
Sorry, this is too advanced for me. Could you please give me a brief description of how to find that PHP snippet or how to “run” it? Do I have to type it in somewhere or do I find it in my wordpress files?
-
Its better to install this plugin – http://wordpress.org/extend/plugins/check-email/
That way you wont need to get into coding. If you can send mails using above plugin, then most likely PHP-mail sending is working fine.
-
-
Karthick
Thanks for the troubleshooting steps. I have followed them
Check point 1 – no issues with PHP setting e-mail goes
Checkpoint 2 – the plugin says “The test email has been sent by WordPress” but actually e-mail is not received. It looks all weird. Any clues on what’s happening to me?-
Check postfix logs and wordpress error logs. Most likely its an issue with WordPress.
Or you might have added your test email address' domain in postfix's
mydestinationlist.
-
-
frank
I used check mail today with WordPress 3.5.1 and it still works great. I was able to fix some email issues in seconds.
Great post by the way.
-
jpdave
Thanks a lot .. it helped me a lot .. In ubuntu we just have to type sudo apt-get install sendmail and then you can send email from wordpress.
-
It’s better to use postfix. It’s sendmail compatible and is more powerful.
You can try it if you ever run into issues with sendmail.
-
-
Prakash
I have configure but I am not able to send any mail using the following command
echo “Test mail from postfix” | mail -s “Test Postfix” athi4prakash@gmail.compls help me out
-
Paula Viegas
Hello guys,
My name is Paula, I’m venturing on WordPress and I am creating my own website. I take this opportunity to apologize for my English because I am Brazilian and my English is not perfect yet. But I think you will understand me and help me 🙂
I bought a theme on ThemeForest, i’m installation normally, but the contact form is having problems with the variables used.
Let me explain: the form has 3 fields (Name , Email and Message), the visitor fills out and submits, however, get only the name and email address of the visitor, but the message that I do not get visitor wrote.
I am in contact with the support of the theme for almost 10 days and are not solving. Perhaps because of problems with their language (french).
I’m not a programmer, but I decided the little I know, I see clearly wrong in the formmail code (refer to fields / variables used).
See if you can help me solve:
– Send_mail.php : http://pastebin.com/MMjEnAy0
– Contact.php : http://pastebin.com/dd1Km2HgIf you need any more information or file, I can post too.
Attached pdf file showing how am receiving emails in my inbox.
Well, the file “send_mail.php” ‘m finding strange line 6 ( $ msg = ” ). Such is not the variable that should be written with any value or different?
Sorry, as I said, I’m not a programmer, I went by instinct and curiosity even. If you can help me, I am sooooo thankful.
Thanks in advance to all.
Paula Viegas
-
Paula Viegas
Ready, is now working! Just swapped $ _REQUEST [Message] to $ _REQUEST [message] and problem solved.
-
Glad to know your issue got fixed. 🙂
-
-
-
Hi there;
This certainly seemed like the best place to post my issue and wondered if you could point me in the right direction.
I have an odd scenario, we run a nginx setup with wordpress, and woocommerce. Now most of our emails are sent out to users (60%), however, it doesn’t matter which plugin, or system that is engaged, about 40% of them fail (they are not sent to junk mail or similar, they just don’t arrive at all).
WordPress’s sendmail function certainly works, and I cannot see a pattern to the issue, so wondered if you had any suggestions as to what I might look out for, as it has totally perplexed me (I’ve even checked blacklist registers etc. which I know it couldn’t really be).
Many thanks for any and all suggestions in advance
-
Check postfix mail log. You will see why mails are getting rejected there.
-
You should also debug amavis if you have it running on the server.
We had a similar problem where 80% of emails would be sent and it bugged us for months until we discovered amavis was the culprit. We removed it from the linux server and the problem went away.
-
Thanks for adding your points. 🙂
We also use amavis (without any issue) and if that is creating any issue, postfix mail.log will have entries about it.
-
-
-
Katalin
Hi,
I try to send mail from my wordpress site, it seems like both mail() and wp_mail() returns true, but the mails don’t arrive. Tried with a test.php from the same server, and still mail() gets true, but no email arrives to my account. I tried the echo “Test from Postfix” | mail -s “Test1” email from terminal and it works.I have no idea at this point. Checked the sendmail path, and smtp settings, and they seems to be as supposed.
Do you have some suggestions?
Thanks,
Katalin-
Katalin
I also checked the php.ini configurations for terminal and php with and php -i and the options smtp, sendmail_path, sendmail_from, smtp_port are the same. Why does it work from terminal but not from .php?
-
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
This field is for validation purposes and should be left unchanged.
Email*
SIGN ME UP
Δ
© rtCamp, since 2009. All rights reserved.
