Last active
April 15, 2021 21:19
-
-
Save Bovelett/5085ec590d9edc265c63bbb35ab685d3 to your computer and use it in GitHub Desktop.
SMTP via WordPress Functions.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// WARNING!! DO NOT USE ON A MULTI USER SETUP. password is not hashed! | |
// Configures WordPress to use SMTP server | |
define( 'SMTP_USER', 'hello@yoursite.com' ); // Username to use for SMTP authentication | |
define( 'SMTP_PASS', 'SMTP_PASSWORD' ); // Password to use for SMTP authentication | |
define( 'SMTP_HOST', 'smtp.smtpserver.com' ); // The hostname of the mail server | |
define( 'SMTP_FROM', 'hello@yoursite.com' ); // SMTP From email address | |
define( 'SMTP_NAME', 'FROM_NAME' ); // SMTP From name | |
define( 'SMTP_PORT', '25' ); // 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 | |
// Configures SMTP authentication | |
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