Skip to content

Instantly share code, notes, and snippets.

@chrdesigner
Last active June 20, 2024 21:07
Show Gist options
  • Select an option

  • Save chrdesigner/6550f7a08cc125f5066c47e82cecd0f1 to your computer and use it in GitHub Desktop.

Select an option

Save chrdesigner/6550f7a08cc125f5066c47e82cecd0f1 to your computer and use it in GitHub Desktop.
Configure manual SMTP

=== GMAIL ===

Password: You can generate an App password. Using this Google App Password Link or go to Google Account Settings>Security>App Password.

<?php
//Create phpmailer SMTP
add_action( 'phpmailer_init', 'chr_phpmailer_smtp' );
function chr_phpmailer_smtp( $phpmailer ) {
$phpmailer->isSMTP();
$phpmailer->Host = SMTP_server;
$phpmailer->SMTPAuth = SMTP_AUTH;
$phpmailer->Port = SMTP_PORT;
$phpmailer->Username = SMTP_username;
$phpmailer->Password = SMTP_password;
$phpmailer->SMTPSecure = SMTP_SECURE;
$phpmailer->From = SMTP_FROM;
$phpmailer->FromName = SMTP_NAME;
}
<?php
// SMTP email settings
define( 'SMTP_username', '[email protected]' ); // username of host like Gmail
define( 'SMTP_password', 'password' ); // password for login into the App
define( 'SMTP_server', 'smtp.mail.com' ); // SMTP server address
define( 'SMTP_FROM', '[email protected]' ); // Your Business Email Address
define( 'SMTP_NAME', 'CHR Designer' ); // Business From Name
define( 'SMTP_PORT', '587' ); // Server Port Number
define( 'SMTP_SECURE', 'tls' ); // Encryption - ssl or tls
define( 'SMTP_AUTH', true ); // Use SMTP authentication (true|false)
define( 'SMTP_DEBUG', 0 ); // for debugging purposes only
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment