Welcome Guest, Not a member yet? Register   Sign In
Can't send server emails in CodeIgniter 4
#1
Sad 

Dear CodeIgniter team,

I just hanged up to send server emails.

I'm preparing email sending code like this:

PHP Code:
$email_config = Array(
    'charset' => 'utf-8',
    'mailType' => 'html'
);

$email = \Config\Services::email();
$email->initialize($email_config);

$email->setNewline("\r\n");
$email->setCRLF("\r\n");
$email->setFrom("[email protected]""Sender name");

$email->setTo("[email protected]");
$email->setSubject("Test message");
$email->setMessage("Hello");

if (
$email->send()) {
    echo "Email sent!";
} else {
    echo $email->printDebugger();
    return false;



It's showing this error message:

Code:
Unable to send email using PHP mail(). Your server might not be configured to send mail using this method.
Date: Thu, 4 Jun 2020 05:21:47 -0500
From: "Sender name" <[email protected]>
Return-Path: <[email protected]>
Reply-To: <[email protected]>
User-Agent: CodeIgniter
X-Sender: [email protected]
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <[email protected]>
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="B_ALT_5ed8cb3ba9e702.65790334"
=?UTF-8?Q?Test=20message?=
This is a multi-part message in MIME format.
Your email application may not support this format.

--B_ALT_5ed8cb3ba9e702.65790334
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Hello


--B_ALT_5ed8cb3ba9e702.65790334
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Hello

--B_ALT_5ed8cb3ba9e702.65790334--

And giving an error in error log:

Code:
Email: sendWithMail throwed Use of undefined constant INTL_IDNA_VARIANT_UTS46 - assumed 'INTL_IDNA_VARIANT_UTS46'
(this will throw an Error in a future version of PHP)

I want to mention that,

  1. intl extension is enabled in server.
  2. I'm using cPanel.
  3. It's working fine on Codeigniter 3.
  4. The mail function is working with the row method in my server like this:
PHP Code:
$to '[email protected]';
$subject 'Test message';
$message 'Hello';
$headers 'From: [email protected]"\r\n" .
        'Reply-To: [email protected]"\r\n" .
        'X-Mailer: PHP/' phpversion();
mail($to$subject$message$headers); 

Please help.

Thanks in advance.
Reply
#2

What PHP version are you using?
Reply
#3

(06-05-2020, 10:40 AM)jreklund Wrote: What PHP version are you using?


I'm using PHP 7.3.18
Reply
#4

(This post was last modified: 06-05-2020, 12:52 PM by jreklund.)

You could hack it away, but I would contact your service provider instead. That's a really old version of ICU you are using. 4.6 where released in 2011, so it's time they upgrade their servers.
http://site.icu-project.org/download/46

ICU are used in PHP intl package.
Reply
#5

Okay. I'll notify to my hosting provider to update this and get back to you with the response.

Thanks for your feedback.
Reply
#6
Smile 

Yes, that was the issue. It's fixed now. Thank you so much...
Reply
#7

No problem! Glad it worked out for you.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB