Welcome Guest, Not a member yet? Register   Sign In
SMTP EMail sending issue
#1
Question 

Heya,
We're transitioning vom our old Windows Server running Xampp, PHP 7.4 with Codeigniter 3 to our new Windows Server running Xampp, PHP 8.1 with Codeigniter 4. Both servers are within the same network.
I've spent around an insane amount of hours re-writing the 50,000+ lines of PHP, but nothing compares to how much time I've wasted with getting a simple E-mail to send...

Here is the error I'm getting, with personalised data replaced with crap like domain.com.  The configs are 100% identical to the CI3 version.  Username, password etc is 100000% correct.
It could be a Windows issue, a PHP8.1 issue or a CI4 issue. I just can't figure this out.  Spent around 6 hours on troubleshooting and now given up and hoping someone has experienced this before.

Code:
Unable to send email using SMTP. Your server might not be configured to send mail using this method.
Date: Thu, 7 Dec 2023 15:55:50 +0000
MIME-Version: 1.0; charset=utf-8
Content-type: text/html
From: "John Doe" <[email protected]>
Return-Path: <[email protected]>
To: [email protected]
Subject: =?UTF-8?Q?Test=20Email=20from=20CodeIgniter=204?=
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




Code:
<?php

namespace App\Controllers;

use CodeIgniter\Controller;
use CodeIgniter\Email\Email;



class sendemail extends BaseController {

function __construct(){
    } 


public function index()
{
return 'nothing to see here';
}


public function phpinfo(){
phpinfo();
}

public function test(){
error_reporting(E_ALL);
    ini_set('display_errors', '1');

$email = new Email();

$config = [
'protocol'  => 'smtp',
'SMTPHost' => 'ssl://mail.domain.com',
'SMTPPort' => 465,
'SMTPUser' => '[email protected]',
'SMTPPass' => 'supersecurepassword',
'newline' => "\r\n",
'mailType'  => 'html',
'charset'  => 'utf-8',
'wordWrap'  => true
];

$email->initialize($config);

$email->setHeader('MIME-Version', '1.0; charset=utf-8');
$email->setHeader('Content-type', 'text/html');
$email->setFrom('[email protected]', 'John Doe');
$email->setTo('[email protected]');
$email->setSubject('Test Email from CodeIgniter 4');
$email->setMessage('This is a test email sent from CodeIgniter 4.');


if ($email->send()) {
echo 'Email successfully sent to [email protected]';
} else {
$data = $email->printDebugger(['headers']);
print_r($data);
}
}
Reply


Messages In This Thread
SMTP EMail sending issue - by cycyx - 12-07-2023, 09:03 AM
RE: SMTP EMail sending issue - by kenjis - 12-07-2023, 09:09 PM
RE: SMTP EMail sending issue - by cycyx - 12-08-2023, 08:52 AM
RE: SMTP EMail sending issue - by davis.lasis - 12-08-2023, 12:12 PM
RE: SMTP EMail sending issue - by kenjis - 12-08-2023, 05:18 PM



Theme © iAndrew 2016 - Forum software by © MyBB