While this works just fine, I am concerned that it poses a security threat. Does it?
add_action( 'phpmailer_init', 'send_email_using_smtp' );
function bsend_email_using_smtp( $phpmailer ) {
$phpmailer->isSMTP();
$phpmailer->Host = 'mail.example.com';
$phpmailer->SMTPAuth = true;
$phpmailer->Port = 465;
$phpmailer->Username = '[email protected]';
$phpmailer->Password = 'your-email-account-password';
$phpmailer->SMTPSecure = 'ssl';
$phpmailer->From = 'name@example.com';
$phpmailer->FromName = 'Your company name';
}
defined('ABSPATH') || exit;
, if you have it, even if you don't this would not be visible. You could use something like bedrock which allows you to create environments and credentials before the root folder (as it changes it), that way nobody could every target those folders directly.