jrobinsonc
8/31/2016 - 8:07 PM

WordPress: SMTP configuration

WordPress: SMTP configuration

<?php

define('SMTP_DSN', 'smtp://user:pass@host:25?auth=1');

// Do not edit below this line.
add_action('phpmailer_init', function($phpmailer) {

    if (! defined('SMTP_DSN'))
        return;

    $smtp_data = parse_url(SMTP_DSN);
    parse_str($smtp_data['query'], $smtp_data_query);

    $phpmailer->isSMTP();
    $phpmailer->Host = $smtp_data['host'];
    $phpmailer->SMTPAuth = isset($smtp_data_query['auth'])? boolval($smtp_data_query['auth']) : false;
    $phpmailer->Port = $smtp_data['port'];
    $phpmailer->Username = $smtp_data['user'];
    $phpmailer->Password = $smtp_data['pass'];
});