Created
July 2, 2021 11:06
-
-
Save mmilosheski/2c33fb24c5208ca1e60840de79c222cc to your computer and use it in GitHub Desktop.
WordPress PHPMailer SMTP
This file contains hidden or 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 | |
use PHPMailer\PHPMailer\PHPMailer; | |
class SMTP { | |
public function __construct() { | |
add_action('phpmailer_init', [$this, 'configure_smtp']); | |
} | |
public function configure_smtp(PHPMailer $phpmailer) { | |
$phpmailer->isSMTP(); | |
$phpmailer->Host = 'server.hostname.or.serverip'; | |
$phpmailer->Port = '587'; | |
$phpmailer->SMTPSecure = true; | |
$phpmailer->SMTPAuth = true; | |
$phpmailer->Username = '[email protected]'; | |
$phpmailer->Password = 'password'; | |
$phpmailer->From = '[email protected]'; | |
$phpmailer->FromName = 'DigitalSilk'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
class SMTP_settings {
}
if (is_admin()){
$smtp_settings = new SMTP_settings();
}
// $smtp_settings_options = get_option( 'smtp_settings_option_name' );
// $smtp_server = $smtp_settings_options['smtp_server'];
// $smtp_port = $smtp_settings_options['smtp_port'];;
// $smtp_secure = $smtp_settings_options['smtp_secure'];
// $smtp_auth = $smtp_settings_options['smtp_auth'];
// $smtp_username = $smtp_settings_options['smtp_username'];
// $smtp_password = $smtp_settings_options['smtp_password'];
// $smtp_mail_from_sender = $smtp_settings_options['smtp_mail_from_sender'];
// $smtp_mail_from_name = $smtp_settings_options['smtp_mail_from_name'];