Forums

WordPress sendmail not working under certain circumstances (4 posts)

  1. cagsmith
    Member
    Posted 10 months ago #

    Greetings everyone,

    I recently migrated my wordpress site and DB to a new host. Previously I was on a shared Linux host, and am now on a shared Windows host. I had read various stories about WP not playing nice under Windows, but despite a couple of teething problems, everything went pretty smoothly... until today. I published a new post and wondered why I was not getting any comments. I checked out my site and noticed that I had in fact received comments, but had received no email notification of them.

    I wanted to know if it was sending emails at all, ever, so I registered a new user and sure enough, I received an email saying that "a new user has registered".

    I've checked php_info and sendmail is enabled, although sender path is blank.

    Here's what works:
    - password resets and user registration notifications (seemingly mail events triggered by wordpress admin)
    - messages sent by a plugin "Fast, Secure Contact Form", although it *seems* that it uses it's own method of sending mail, not anything related to sendmail directly.

    Here's what doesn't work:
    - notifications to me and notifications to visitors, triggered by a plugin "Comment Notifier" (seemingly mail events triggered through posts).

    What I've tried:
    - Downloaded multiple plugins which attempt to force WP to send notifications via SMTP and not through PHP sendmail. I can send a test mail once these plugins are configured, but they still won't send comment notifications etc (and sending via SMTP seems really slow!)

    - Checked around and it seems it's possible to correct this by hacking php.ini a bit, but as it's a shared hosting environment, the php.ini is located in C:\Windows\ - A location I don't have access to.

    And so:
    So, I was wondering - has anyone ever heard of this? It seems like maybe a permission issue somewhere, since SOME mails are sent, but not all (although ideally I'd like a bit more control over even the new user notifications, because at the moment they're all coming from "Windows@Hostgator.com" - I'd much rather they come from my site's email address.

    Hope you can help, and thanks for your time!

  2. chief-uk
    Member
    Posted 7 months ago #

    I have the same problem, and think I know the solution... you need an extra parameter of -f (from) and a valid email address on your host. Just going to attack the code, will let you know what I find.

  3. chief-uk
    Member
    Posted 7 months ago #

    Found it...

    in wp-includes/class-phpmailer.php
    line 84

    /**
       * Sets the From email address for the message.
       * @var string
       */
      public $From = 'root@localhost';

    change root@localhost to an email address on your site, e.g. noreply@example.com

    This fixed it for me, plus you have a few other fixed variables in the next few sections you may also want to change.

  4. cagsmith
    Member
    Posted 7 months ago #

    Thanks a lot - looks hopeful. I'll have a peek tonight :)

Reply

You must log in to post.

About this Topic