Open
Description
PHP Version
8.3
CodeIgniter4 Version
4.6.0
CodeIgniter4 Installation Method
Composer (using codeigniter4/appstarter
)
Which operating systems have you tested for this bug?
Linux
Which server did you use?
fpm-fcgi
Database
No response
What happened?
I've tried to setup email sender using CodeIgniter Email class. I use SMTP configuration with SMTPCrypto=tls, SMTPPort=587 and other auth configuration. Then it shows this debug message:
hello:
The following SMTP error was encountered:
starttls:
The following SMTP error was encountered:
Unable to send email using SMTP. Your server might not be configured to send mail using this method.
Date: Wed, 12 Feb 2025 17:35:25 +0700
To: [email protected]
Subject: =?UTF-8?Q?SMTP=20Email=20Testing?=
From: "Masagi" <[email protected]>
Return-Path: <[email protected]>
Reply-To: <[email protected]>
User-Agent: Tarbiyya
X-Sender: [email protected]
X-Mailer: Tarbiyya
X-Priority: 3 (Normal)
Message-ID: <[email protected]>
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="B_ALT_67ac796d34a404.14803652"
This is a multi-part message in MIME format.
Your email application may not support this format.
--B_ALT_67ac796d34a404.14803652
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This is sample body of email testing using SMTP.
--B_ALT_67ac796d34a404.14803652
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
This is sample body of email testing using SMTP.
--B_ALT_67ac796d34a404.14803652--
For comparison, I try to use PHPMailer package with same configuration I've set in Config\Email class and it sent the message successfully. I use SMTP account from Hostinger.
Steps to Reproduce
This is my sample code:
// CodeIgniter Email
$email = service("email");
$email->setTo("[email protected]");
$email->setSubject("SMTP Email Testing");
$email->setMessage("This is sample body of email testing using SMTP.");
$email->send(false);
echo $email->printDebugger();
// PHPMailer
$mail = new PHPMailer(true);
$EmailConfig = new \Config\Email;
try {
$mail->SMTPDebug = SMTP::DEBUG_SERVER;
$mail->isSMTP();
$mail->Host = $EmailConfig->SMTPHost;
$mail->SMTPAuth = true;
$mail->Username = $EmailConfig->SMTPUser;
$mail->Password = $EmailConfig->SMTPPass;
$mail->SMTPSecure = $EmailConfig->SMTPCrypto; // 'tls'
$mail->Port = $EmailConfig->SMTPPort; // 587
$mail->setFrom($EmailConfig->fromEmail, $EmailConfig->fromName);
$mail->addAddress('[email protected]');
$mail->isHTML(true);
$mail->Subject = 'SMTP Email Testing';
$mail->Body = 'This is sample body of email testing using SMTP.';
$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
Expected Output
I don't know if I missed something in my configuration or if there is an error in the Email class.
Anything else?
No response
Metadata
Metadata
Assignees
Labels
No labels