• sphakka

    (@sphakka)


    Hi there,

    I configured my Hivepress installation to use PHPMailer/SMTP with a custom configuration, mainly to override the “From:” feld. Here’s the code in functions.php (SMTP_* defs comes from config):

    add_action(
    'phpmailer_init',
    function ( $phpmailer ) {
    $phpmailer->SMTPDebug = SMTP_DEBUG ? SMTP::DEBUG_SERVER : SMTP::DEBUG_OFF;

    $phpmailer->isSMTP();
    $phpmailer->Host = SMTP_HOST;
    $phpmailer->Port = SMTP_PORT;
    $phpmailer->Username = SMTP_USER;
    $phpmailer->Password = SMTP_PASS;
    $phpmailer->From = SMTP_FROM;
    $phpmailer->FromName = SMTP_FROMNAME;
    $phpmailer->SMTPAuth = SMTP_AUTH;
    $phpmailer->SMTPSecure = SMTP_SECURE ? PHPMailer::ENCRYPTION_SMTPS : '';
    $phpmailer->Timeout = SMTP_TIMEOUT;
    }
    );

    Emails are sent and delivered but never confirmed on the form page (no [green] feedback box appears), the spinner stays on forever, the page doesn’t reload. No debug log message on the server side. The Firefox console shows:

    Object { code: "invalid_json", message: "The response is not a valid JSON response." }
    code: "invalid_json"
    message: "The response is not a valid JSON response."
    <prototype>: Object { … }
    __defineGetter__: function __defineGetter__()
    __defineSetter__: function __defineSetter__()
    __lookupGetter__: function __lookupGetter__()
    __lookupSetter__: function __lookupSetter__()
    ??__proto__:
    ??constructor: function Object()
    ?hasOwnProperty: function hasOwnProperty()
    ?isPrototypeOf: function isPrototypeOf()
    ?propertyIsEnumerable: function propertyIsEnumerable()
    ?toLocaleString: function toLocaleString()
    ??toString: function toString()
    ??valueOf: function valueOf()
    <get __proto__()>: function __proto__()??
    <set __proto__()>: function __proto__()
    index.js:1:6726

    Any idea why?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    Where can we see the website in question?

    Thread Starter sphakka

    (@sphakka)

    Oops, here it is: https://secondemain.cas-geneve.ch/contact/

    Versions:

    • WP-6.61
    • CF7-5.9.8
    • HivePress-1.7.7
    • ListingHive-1.2.9
    • PHP-8.2

    I also added wp_mail_failed and wp_mail_succeded hooks to log errors and the sent mail’s content, but nothing is logged. It looks like those actions are never triggered: possibly $phpmailer->send() never returns?

    • This reply was modified 3 months ago by sphakka.
    • This reply was modified 3 months ago by sphakka.
    Thread Starter sphakka

    (@sphakka)

    By further debugging, I discovered that PHPMailer\SMTP() has an option to specify the debug output format. Guess what? I set this to

    $phpmailer->Debugoutput = 'error_log';

    in the phpmailer_init hook, and… bingo! CF7 worked again!? There’s definitely some weird interaction with WP/PHP’s logging subsystem because:

    1. Disabling SMTP debugging (d’oh, I should have tried it before!) restores correct CF7 functioning.
    2. With SMTP debugging set to SMTP::DEBUG_LOWLEVEL, I can’t get the full log, only an excerpt like:
    [27-Aug-2024 14:35:15 UTC] Sending with mail()
    [27-Aug-2024 14:35:15 UTC] Sendmail path: /usr/sbin/sendmail -t -i
    [27-Aug-2024 14:35:15 UTC] Envelope sender:code
    ...

    So, I have a workaround, but would appreciate some feedback from experts. There might still be a bug with CF7.

    BTW, this is happening on a shared hosting instance, so I don’t have full access to the server logs.

    Plugin Author Takayuki Miyoshi

    (@takayukister)

    What other plugins and theme do you use on the site?

    Thread Starter sphakka

    (@sphakka)

    Here are the plugins (‘no-comment’ just disable the blog’s comment/ping, etc. functions — no JS installed. Code here):

    $ wp plugin list
    +------------------------+----------+--------+---------+----------------+-------------+
    | name | status | update | version | update_version | auto_update |
    +------------------------+----------+--------+---------+----------------+-------------+
    | cf7-conditional-fields | active | none | 2.4.15 | | off |
    | contact-form-7 | active | none | 5.9.8 | | off |
    | hivepress | active | none | 1.7.7 | | off |
    | hivepress-messages | active | none | 1.3.0 | | off |
    | loco-translate | active | none | 2.6.11 | | off |
    | really-simple-captcha | active | none | 2.3 | | off |
    | wp-rollback | active | none | 2.0.7 | | off |
    | no-comment | must-use | none | | | off |
    +------------------------+----------+--------+---------+----------------+-------------+

    I’ll try to deactivate some plugins selectively and report.

    No other theme installed apart from mine which is a child of latest ListingHive and just uses some CSS and PHP tweaks. The functions.php is here.

    Plugin Author Takayuki Miyoshi

    (@takayukister)

    Try switching to the default theme, deactivating all plugins excluding Contact Form 7 and Really Simple CAPTCHA, and clearing all cache data.

    Why you are advised to deactivate plugins and switch to the default theme.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.