FeaturesWP CloudPricingEE CLIContactMy Account

Features

Team Access & User Permissions

Server Setup & Management

Site Creation & Management

Deployments & Developer Tools

Firewall Protection

Speed & Caching

Backups & Recovery

Logs & Monitoring

Create WP Cloud Sites

All Features

Read Documentation

Install

Installation Guide

FAQ

Roadmap

Explore EE CLI

Resources

Commands

Handbook

Blog

Community

Forum

EasyExperts

Tutorials

Subscribe

Github

CLEAR

Start For Free

separator Tutorials separator PHP separator Checking if PHP/WordPress can send mails

Topics

On this page

First check if PHP-scripts can send emails

Check if WordPress can send emails

Checking if PHP/WordPress can send mails

NGinx

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

  1. KardiWeb Avatar

    KardiWeb

    January 29, 2013

    Hello!

    What is sendmail_path in php.ini?

    Thank you!

    1. Rahul Bansal Avatar

      Rahul Bansal

      February 8, 2013

      Its a path to sendmail program on your server.

      On Linux, just run command:

      which sendmail
      

      It will show you path like:

      /usr/sbin/sendmail
      

      In 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.

  2. KardiWeb Avatar

    KardiWeb

    March 4, 2013

    I’m doing all of this assistance. does not work :/

    1. Rahul Bansal Avatar

      Rahul Bansal

      March 4, 2013

      Sorry but I couldn’t understood what you wanted to say.

      Please ask your question more clearly (may be with some details).

  3. Dale Avatar

    Dale

    March 17, 2013

    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.com

    It 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?

    1. Rahul Bansal Avatar

      Rahul Bansal

      March 18, 2013

      Please check error.log file 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.

  4. Dale Avatar

    Dale

    March 19, 2013

    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/

    1. Rahul Bansal Avatar

      Rahul Bansal

      March 19, 2013

      @Dale

      Glad to know that your issue got fixed. 🙂

    2. ken Avatar

      ken

      March 29, 2013

      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.

      1. Rahul Bansal Avatar

        Rahul Bansal

        June 3, 2013

        @Ken
        Sorry for delayed reply. If you are facing issues as of now, please send error logs.

  5. Andree Avatar

    Andree

    July 22, 2013

    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

    1. Rahul Bansal Avatar

      Rahul Bansal

      July 25, 2013

      @Andree

      I did not get what you are trying to ask?

  6. Bastian Avatar

    Bastian

    July 27, 2013

    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?

    1. Rahul Bansal Avatar

      Rahul Bansal

      September 24, 2013

      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.

  7. Karthick Avatar

    Karthick

    September 16, 2013

    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?

    1. Rahul Bansal Avatar

      Rahul Bansal

      September 17, 2013

      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 mydestination list.

  8. frank Avatar

    frank

    September 24, 2013

    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.

  9. jpdave Avatar

    jpdave

    November 15, 2013

    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.

    1. Rahul Bansal Avatar

      Rahul Bansal

      November 16, 2013

      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.

  10. Prakash Avatar

    Prakash

    January 1, 2014

    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.com

    pls help me out

    1. Rahul Bansal Avatar

      Rahul Bansal

      January 1, 2014

      Please try https://rtcamp.com/tutorials/mail/postfix-debugging/

  11. Paula Viegas Avatar

    Paula Viegas

    March 15, 2014

    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/dd1Km2Hg

    If 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

    1. Paula Viegas Avatar

      Paula Viegas

      March 15, 2014

      Ready, is now working! Just swapped $ _REQUEST [Message] to $ _REQUEST [message] and problem solved.

      1. Rahul Bansal Avatar

        Rahul Bansal

        March 16, 2014

        Glad to know your issue got fixed. 🙂

  12. Erryn Avatar

    Erryn

    March 22, 2014

    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

    1. Rahul Bansal Avatar

      Rahul Bansal

      March 22, 2014

      Check postfix mail log. You will see why mails are getting rejected there.

    2. frank Avatar

      frank

      March 24, 2014

      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.

      1. Rahul Bansal Avatar

        Rahul Bansal

        March 24, 2014

        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.

  13. Katalin Avatar

    Katalin

    March 24, 2014

    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

    1. Katalin Avatar

      Katalin

      March 24, 2014

      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?

      1. Rahul Bansal Avatar

        Rahul Bansal

        March 24, 2014

        try https://rtcamp.com/tutorials/mail/postfix-debugging/

Features

Useful Links

Product

Other Products

Subscribe for curated product updates, tips, and announcements.

"*" indicates required fields

Facebook

This field is for validation purposes and should be left unchanged.

Email*

SIGN ME UP

Δ


© rtCamp, since 2009. All rights reserved.

Powered by