Skip to content

Instantly share code, notes, and snippets.

@alinademi
Forked from josanua/send_smtp_with_wpmail.php
Created January 30, 2021 03:05
Show Gist options
  • Save alinademi/ee021c8fa62e1b8622f5ab451efe2dd6 to your computer and use it in GitHub Desktop.
Save alinademi/ee021c8fa62e1b8622f5ab451efe2dd6 to your computer and use it in GitHub Desktop.
Wordpress: Add SMTP settings to wp_mail()
// Action for change default system settings, it work's!
add_action('phpmailer_init','send_smtp_email');
function send_smtp_email( $phpmailer )
{
// Define that we are sending with SMTP
$phpmailer->isSMTP();
// The hostname of the mail server
$phpmailer->Host = "your server smtp address";
// Use SMTP authentication (true|false)
$phpmailer->SMTPAuth = true;
// SMTP port number - likely to be 25, 465 or 587
$phpmailer->Port = "587";
// Username to use for SMTP authentication
$phpmailer->Username = "user name";
// Password to use for SMTP authentication
$phpmailer->Password = "password";
// The encryption system to use - ssl (deprecated) or tls
$phpmailer->SMTPSecure = "tls";
$phpmailer->From = "Mail account";
$phpmailer->FromName = "Name account";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment