Wordpress Custom Contact Form Plugin Not Working On Live Envrioment

Posted December 21, 2014 9.7k views



I created a custom contact form plug-in, it also uses the WP-Mail-SMTP plugin for smtp email sending. It is working on my local development environment, but not on my live environment. When i use the WP-Mail-SMTP plugin to send a test email, that works fine.

It returns Error Sending Message Instead of the Thanks for contacting me message. I receive no email in my inbox.

So i tried this guys small plug-in to send an email to my self.

This worked on my local environment as does my own plug-in but again does not work on live environment.

So we can rule out it’s nothing to do with the plug-in code?

What’s stopping this from working on live?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

Sounds like your sendmail function is missing. Let’s try this. SSH into your server and trying sending and email using the following code. Don’t forget to replace ’ with a valid email.

sendmail Body of Test Message

Also, how did you installed wordpress, as a One-Click install or manually?

  • just to add to this (I agree it sounds like sendmail is not installed). Run these commands:

    sudo apt-get install sendmail

    and then you have to configure sendmail. Just choose the default answers to continue through each question and you should be fine:

    sudo sendmailconfig

    that should do it, but if not try rebooting:

    sudo reboot
  • @sierracircle @aguilar1181

    Just out of curiosity why do i need send-mail when the WP-Mail-SMTP plugin tests email works fine on Live?

  • Sorry, I mis-read your question.

    I re-read and realize that you want to use WP-Mail-SMTP to send with, rather than using php mail. I thought you were saying that WP-Mail-SMTP works, but using regular phpmail does not.

    I tried your plugin on a Wordpress install and sending failed. I have WP-Mail-SMTP installed, and use Formidable Pro to create forms and send…which works fine.

    Sounds like you need to do some de-bugging on your script (create a simplified version and see what fails for each step.

    Might help to disable WP-Mail-SMTP and see if it works with regular php mail..

  • I did use a simplified version i used this . and it still did not work.

    Also it doesent explain why because my plugin works in local environment and not live,.

  • Trouble-shooting can be a lot of work.

    I would ask myself these questions:

    does ContactForm7 work on my remote server?
    if not, then does it work just using phpmail?

    does my local environment match my remote server? (same OS version, same packages installed?)
    if not, what are the differences?

  • Might help to disable WP-Mail-SMTP and see if it works with regular php mail..

    If i do the above i would just need to install and configure sendmail correct? Would i be right in saying wpmail only works with smtp which means i cnt use wpmail with sendmail?

  • I tested Using Contact 7, again it works locally but not live. I have pretty much the same setup. Ubuntu 14.04 both local and live same packages

  • So i just tried the Wp-SMTP plugin test email again and this time its returning back false. here is the debug.

    array(18) {
    string(35) “SMTP Error: Could not authenticate.”
    string(43) “SMTP Error: Could not connect to SMTP host.”
    string(30) “SMTP Error: data not accepted.”
    string(18) “Message body empty”
    string(18) “Unknown encoding: ”
    string(19) “Could not execute: ”
    string(23) “Could not access file: ”
    string(33) “File Error: Could not open file: ”
    string(35) “The following From address failed: ”
    string(36) “Could not instantiate mail function.”
    string(15) “Invalid address”
    string(25) “ mailer is not supported.”
    string(54) “You must provide at least one recipient email address.”
    string(45) “SMTP Error: The following recipients failed: ”
    string(15) “Signing Error: ”
    string(22) “SMTP connect() failed.”
    string(19) “SMTP server error: ”
    string(30) “Cannot set or reset variable: ”

  • Could digital ocean be blocking the port or some sort of permission issue?

  • wp-mail uses phpmail, UNLESS Wp-SMTP plugin is installed, which tells it to use the SMTP server instead.

    It could be the ports blocked lik eyou mentioned. you could do:

     sudo iptables -A INPUT -p tcp -d 0/0 -s 0/0 --dport 465 -j ACCEPT

    if you have UFW installed you want to do:

    sudo ufw allow 465

    who is the SMTP server you are using?

    I use a google apps account (same as gmail) with my server, and it works fine.

    port: 465
    Yes, use authentication
    username and password are to the google account

  • …slight update: I just changed one thing on your script and it works for me:

    line 34

                        echo '<form class="contact-form" action="/#contact" method="post">';

    changed to:

                        echo '<form class="contact-form" action="/contact" method="post">';

    now works fine. I have a page named /contact, which is where I inserted the short-code

  • The # was because i was using smooth-scrolling as i had a 1 page app.

    I now understand the problem after speaking with DigitalOcean Support team. It seems that live.smtp has blocked digitalocean IP’s. So this is why it was not working. I will now have to use a 3rd party app and make use of there free service e.g.

  • Thanks for pointing out Mandrill. I have a few clients who send Newsletters. Running up against SMTP sending limits is always a pain. Looks like Mandrill has free up to 12000 a month, with reasonable prices after that.

  • Again ive managed to get gmail working on local, but not on live. :/ This is such a pain!
    port: 465
    Yes, use authentication

  • any luck with this yet? Have you tried opening ports?