'Using global variables in PHPMailer

Instead of this:

$mail->isSMTP();  
$mail->Host = 'smtp.demo-server.com';
$mail->SMTPAuth = true;
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
$mail->Port = 'demo-port';
$mail->Username = '[email protected]'; 
$mail->Password = 'demo-password';

I would like to keep the values in a separate file and use variables instead:

$mail->isSMTP();  
$mail->Host = echo $server; // also tried without echo
$mail->SMTPAuth = true;
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
$mail->Port = echo $port;
$mail->Username = echo $username; 
$mail->Password = echo $password;

I'm already using output buffering, have set the global scope, and the variable values contain the quotes. Still not working.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source