Adicionar SMTPOptions, SMTPDebug e Debugoutput nos parametros de configuração
rabraga opened this issue · 0 comments
rabraga commented
Boas!
Seguindo a mesma lógica do ISSUE 49 (#49) precisei incluir no sped-email\vendor\nfephp-org\sped-mail\src\Mail.php os atributos SMTPOptions, SMTPDebug e Debugoutput.
Os atributos SMTPDebug e Debugoutput é para facilitar o debug e descobrir erros de conexão.
Quando tls preciso enviar para a classe o SMTPOptions para que o servidor consiga fazer a autenticação.
if ($config_email->secure == 'tls') {
$config_email->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
}
Segue função alterada e testada, OK!
protected function loadService(\stdClass $config)
{
$this->mail->CharSet = 'UTF-8';
$this->mail->isSMTP();
$this->mail->Host = $config->host;
$this->mail->SMTPAuth = $config->smtpauth;
if (!empty($config->user) && !empty($config->password)) {
$this->mail->SMTPAuth = true;
$this->mail->Username = $config->user;
$this->mail->Password = $config->password;
}
$this->mail->SMTPSecure = $config->secure;
$this->mail->Port = $config->port;
if (!empty($config->authtype)) {
$this->mail->AuthType = $config->authtype;
}
if (!empty($config->timeout)) {
$this->mail->Timeout = $config->timeout;
}
if (!empty($config->timelimit)) {
$this->mail->Timelimit = $config->timelimit;
}
if (is_array($config->SMTPOptions)) { // RABRAGA - 280819
$this->mail->SMTPOptions = $config->SMTPOptions;
}
if (!empty($config->SMTPDebug)) { // RABRAGA - 280819
$this->mail->SMTPDebug = $config->SMTPDebug;
}
if (!empty($config->Debugoutput)) { // RABRAGA - 280819
$this->mail->Debugoutput = $config->Debugoutput;
}
$this->mail->setFrom($config->from, $config->fantasy);
$this->mail->addReplyTo($config->replyTo, $config->replyName);
}