Add the following code to your theme’s functions.php file.
function custom_smtp_settings($phpmailer) {
$phpmailer->isSMTP();
$phpmailer->Host = SMTP_HOST;
$phpmailer->Port = SMTP_PORT;
$phpmailer->Username = SMTP_USER;
$phpmailer->Password = SMTP_PASS;
$phpmailer->FromName = SMTP_NAME;
$phpmailer->From = SMTP_FROM;
$phpmailer->SMTPSecure = SMTP_SECURE;
$phpmailer->SMTPAuth = SMTP_AUTH;
}
add_action(‘phpmailer_init’, ‘custom_smtp_settings’);Define the environment variables in wp-config.php.
define(‘SMTP_HOST’, ‘smtp.mail.me.com’);
define(‘SMTP_PORT’, 587);
define(‘SMTP_USER’, ‘iCloud account’);
define(‘SMTP_PASS’, ‘App Password’);
define(‘SMTP_NAME’, ‘Sender Name’);
define(‘SMTP_FROM’, ‘Sender Email’);
define(‘SMTP_SECURE’, ‘tls’);
define(‘SMTP_AUTH’, true);iCloud Account is your primary email account set up with Apple.
App Password is created at https://account.apple.com.
Sender Email is the email address used for notifications. You must create a custom email address in advance.