Viewing 13 replies - 1 through 13 (of 13 total)
  • Chris Dillon

    (@cdillon27)

    There are several possible reasons.

    Let’s start by checking if the mail protocol is enabled in PHP on your server. If you have access to your server’s php.ini file, look for SMTP and smtp_port. Mine looks like this:

    [mail function]
    SMTP = localhost
    smtp_port = 25

    If you don’t have access to the php.ini file, then create a file called phpinfo.php in your root directory and add this line to it:

    <?php phpinfo(); ?>

    View this in your browser (i.e. https://www.mydomain.com/phpinfo.php) and search the page for SMTP and smtp_port. Delete the file when you’re done so as not to expose any configuration details to prying eyes.

    (Aside: I like to run this page once, copy the page to my Evernote so I have the details for just such an occasion, then delete the page.)

    Or ask your web host tech support if SMTP is enabled in PHP.

    Thread Starter neutraleyes

    (@neutraleyes)

    mine looks the same as yours. now what?
    SMTP localhost localhost
    smtp_port 25 25

    Chris Dillon

    (@cdillon27)

    Good. Now let’s check if the WordPress mail function is working. Use the example script on this site:
    https://www.butlerblog.com/2012/09/23/testing-the-wp_mail-function/

    Thread Starter neutraleyes

    (@neutraleyes)

    it worked.

    Chris Dillon

    (@cdillon27)

    Good. So let’s look at the values the plugin is working with. Add this before the wp_mail function in /wp-content/plugins/gc-testimonials/testimonials.php:

    echo 'To: '.$to.'<br>Subject: '.$subject.'<br>Message: '.$message.'<br>Headers: '.$headers;

    Line 604 if you’re using an editor, or just edit the plugin via the admin screen and search for wp_mail.

    Then add a testimonial using the form. This will show the values right before being sent to wp_mail. No need to post the results, just let me know if the To: address and the From: address in the Headers look correct.

    Thread Starter neutraleyes

    (@neutraleyes)

    I’m just going to post it all instead of trying to explain what i see.

    To: [email protected]
    Subject: Testimonial Submission on Progressive Landscapes
    Message: You have received a testimonial submission on Progressive Landscapes. This is awaiting action from the administrator of the website.
    Headers: From: [email protected] X-Mailer: PHP/5.2.17

    thank you so much for walking me through this so far.
    i have also checked my spam and its not in there either.

    Chris Dillon

    (@cdillon27)

    I’m glad to help. We’ve ruled out the obvious. You can remove that line of code if you haven’t already.

    Let’s try this plugin:
    https://www.ads-software.com/plugins/wp-mail-smtp/
    It adds more control over the mail function.

    Select the options for
    Use the PHP mail() function to send emails.
    and
    No encryption.
    and
    No: Do not use SMTP authentication.
    and be sure to click [Save Changes].
    Then, at the the bottom of that admin page, try a test email. It will tell you whether or not it was able to send.

    If it fails, it lists out the variables and error codes so we’ll need those – just copy that section to Notepad or something and we’ll go from there.

    Thread Starter neutraleyes

    (@neutraleyes)

    test email worked. testimonial email notification still not working.

    Chris Dillon

    (@cdillon27)

    Good, getting closer. I think your web host’s security settings are bit tighter than average. That’s a good thing.

    Let’s try this. In testimonials.php, at line 602 (a couple lines above the wp_mail we searched for before):
    Disable this line by adding 2 slashes in front like this:

    // $headers = 'From: noreply@'.$_SERVER['HTTP_HOST'] . "\r\n" . 'X-Mailer: PHP/' . phpversion();

    then add this line right below it:

    $headers = 'From: noreply@'.str_replace('www.','',$_SERVER['HTTP_HOST']);

    We’re fixing two things here. (1) The headers don’t need the X-Mailer part because the wp_mail function already includes that. (2) Your web host may not like the www in the email address.

    Thread Starter neutraleyes

    (@neutraleyes)

    voila! it works! thanks!
    after all that, i’m kinda disappointed by the email structure/content. i thought it would be more interactive like a comment moderation notification email where the admin wouldn’t have to log in to the website to approve or deny.
    ah well.

    Chris Dillon

    (@cdillon27)

    You’re welcome. I’m glad we figured it out.

    Chris

    chappie

    (@chappie)

    Very impressive, Chris. Thanks for sharing your knowledge. The topic isn’t relevant to me but I love the way you processed the problem and found the solution.

    A thing of beauty.

    Chris Dillon

    (@cdillon27)

    Thank you chappie!

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Admin Email Notification’ is closed to new replies.