Steps
1. You will not be able to send emails when you install WordPress on Google Cloud Platform. To fix it, go to your WordPress’s wp-config.php file and add the following SMTP email settings:
define(‘FORCE_SSL_ADMIN’,false);
define(‘SMTP_USER’, ‘youremail@gmail.com’);
define(‘SMTP_PASS’, ‘yourpassword’);
define(‘SMTP_HOST’, ‘smtp.gmail.com’);
define(‘SMTP_FROM’, ‘youremail@gmail.com’);
define(‘SMTP_NAME’, ‘yourname’);
define(‘SMTP_PORT’, ‘587’);
define(‘SMTP_SECURE’, ‘tls’);
define(‘SMTP_AUTH’, true);
2. Go to WordPress admin panel and browse Appearance/Theme Editor and edit functions.php file of your theme and add the following:
add_action(‘phpmailer_init’,’my_phpmailer_example’);
function my_phpmailer_example($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;
}
Credits
https://www.youtube.com/watch?v=eTqrw3bgfUE&ab_channel=TonyTeachesTech