I have the following case: I want to send an email from cakephp, but since there is more than one user in the database (each containing a different email), I need to send each user's email and password to the / app file /Config/email.php, that is, simply get the session. There is already a method that captures the user's data, being $ this-> Session-> read ('UserList'), so you can pass the rest of the parameters: $ this-> Session-> read ('UserList' ) ['User'] ['email'] and $ this-> Session-> read ('UserLogic') ['User'] ['password'], however when trying to pass these session values to the email file .php, it gives an error saying that it is necessary to use this within a function.
email.php:
public $smtp = array(
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'from' => array($_SESSION['UsuarioLogado']['User']['email'] => $_SESSION['UsuarioLogado']['User']['nome']),
'username' => $_SESSION['UsuarioLogado']['User']['email'],
'password' => $_SESSION['UsuarioLogado']['User']['senha'],
'transport' => 'Smtp',
'tls' => false // As of 2.3.0 you can also enable TLS SMTP
);