This function will connect wp_mail to your authenticated SMTP server
/**
* This function will connect wp_mail to your authenticated
* SMTP server. This improves reliability of wp_mail, and
* avoids many potential problems.
*
*
* Values for constants are set in wp-config.php
*/
function send_smtp_email( $phpmailer ) {
$phpmailer->isSMTP();
$phpmailer->Host = SMTP_HOST;
$phpmailer->SMTPAuth = SMTP_AUTH;
$phpmailer->Port = SMTP_PORT;
$phpmailer->Username = SMTP_USER;
$phpmailer->Password = SMTP_PASS;
$phpmailer->SMTPSecure = SMTP_SECURE;
$phpmailer->From = SMTP_FROM;
$phpmailer->FromName = SMTP_NAME;
}
add_action( 'phpmailer_init', 'send_smtp_email' );
/**
* SMTP setting for wp_mail -> wp-config.php
*
*/
define( 'SMTP_USER', 'email@email.com' ); // Username to use for SMTP authentication
define( 'SMTP_PASS', 'password' ); // Password to use for SMTP authentication
define( 'SMTP_HOST', 'mail.host.com' ); // The hostname of the mail server
define( 'SMTP_FROM', 'email@email.com' ); // SMTP From email address
define( 'SMTP_NAME', 'Reprazent.me' ); // SMTP From name
define( 'SMTP_PORT', '465' ); // SMTP port number - likely to be 25, 465 or 587
define( 'SMTP_SECURE', 'ssl' ); // Encryption system to use - ssl or tls
define( 'SMTP_AUTH', true ); // Use SMTP authentication (true|false)
define( 'SMTP_DEBUG', 0 ); // for debugging purposes only set to 1 or 2