01-22-2021, 05:11 AM
Hi ,sorry for english , thi is my function to send email to recover password with smtp :
The method return TRUE but no mail are send . In codeigniter 3 i must use phpmailer (with same credential work fine) . Must i use phpmailer in codeigniter 4 too ?
PHP Code:
public function send_new_password_by_mail($email_to,$newpassword)
{
$email = \Config\Services::email();
$configuration = new \Config\Common();
$config_smtp['protocol'] = 'smtp';
$config_smtp['SMTPHost'] = 'authsmtp.securemail.pro';
$config_smtp['SMTPUser'] = 'xxxxxxxxxx';
$config_smtp['SMTPPass'] = 'xxxxxxxxxx';
$config_smtp['SMTPPort'] = 465;
$config_smtp['SMTPCrypto'] = 'ssl';
$email->initialize($config_smtp);
$email->setMailType('html');
$email->setFrom($configuration->siteName, $configuration->siteEmail);
$email->setTo($email_to);
//$email->cc('[email protected]');
//$email->bcc('[email protected]');
$email->setSubject('Reset Password ' . $configuration->siteName);
$message = '
<html>
<head>
<title></title>
</head>
<body>
<p>Ricevi questa mail perche` hai chiesto un reset della password sul sito '.$configuration->siteName.'<p>
<p>La tua nuova password e\' : '.$newpassword.'<p>
<p>Esegui il login cliccando <a href="'. base_url().'/login">qui</a> <p>
<p>Se hai ricevuto questa mail per sbaglio non considerarla<p>
<a href="'.$configuration->siteUrl .'">'.$configuration->siteUrl.' <p>
</body>
</html>';
$email->setMessage($message);
if ($email->send()) {
return TRUE;
}else{
return $email->printDebugger();
}
The method return TRUE but no mail are send . In codeigniter 3 i must use phpmailer (with same credential work fine) . Must i use phpmailer in codeigniter 4 too ?