Skip to content

Instantly share code, notes, and snippets.

@daliborgogic
Last active May 12, 2019 18:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daliborgogic/9834228601a62832c2686b6006bf901c to your computer and use it in GitHub Desktop.
Save daliborgogic/9834228601a62832c2686b6006bf901c to your computer and use it in GitHub Desktop.
[SMTP WP] #wp
define('SMTP_USER','mail@example.com'); // Username to use for SMTP authentication
define('SMTP_PASS', '############'); // Password to use for SMTP authentication
define('SMTP_HOST', 'mail.host.com'); // The hostname of the mail server
define('SMTP_FROM', 'mail@example.com'); // SMTP From email address
define('SMTP_NAME', 'Example'); // SMTP From name
define('SMTP_PORT', '587'); // SMTP port number - likely to be 25, 465 or 587
define('SMTP_SECURE', 'tls'); // 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
@daliborgogic
Copy link
Author

// functions.php
add_action( 'phpmailer_init', 'send_smtp_email' );
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;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment