Sending SMTP mail in WordPress via server with self-signed certificate

2

I have a WordPress Multisite (4.3) on a server where the sending of emails is blocked. To send e-mail, an external server with authentication must be used.

By default, WordPress's native wp_mail() veloper function internally uses PHPMailer which in turn calls PHP's mail() fault. This procedure apparently does not use SMTP (?) And does not allow you to configure authentication or other options.

In the past, I had used the wp-mail-smtp plugin to force the use of SMTP and fill in the authentication data.

However, the mail server uses a self-signed certificate and apparently from PHP 5.6 (which is the version used by WP) has introduced certificate validation, causing failure to send, unless I use the following parameters: / p>

$mail->SMTPOptions = array(
    'ssl' => array(
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true
    )
);

( source )

I can successfully send emails from a test script. But I do not know how to force WordPress to apply this setting. No plugin I found supports them, and the solution I found suggests editing functions.php , which my seeing would be a solution that would only apply to that theme on that particular site.

How do I make something work for all multisite sub-sites?

    
asked by anonymous 27.08.2015 / 17:45

1 answer

1

It's an interesting tool in single sites , but almost essential for Multisites:

Must Use Plugins «WordPress Codex

All scripts you put into the wp-content/mu-plugins folder will run automatically without the need for activation, well before the other plugins and generally on all sites in the network.

You can restrict your execution to this or that site.

As far as I know, that Eugene solution you found is what solves your problem, with special attention to the answer from Master Kaiser . Just create a PHP file with that code and put it inside /mu-plugins . If you put a plugin header , the list gets more elegant at /wp-admin/network/plugins.php

As you apparently do not know them, the various answers I wrote using the Must Use Plugins in WPSE and in the SOen .

    
11.09.2015 / 09:41