Why CodeIgniter Email Silently Fails
Most CodeIgniter email problems on shared hosting trace back to one decision made during development: the application was wired to use the mail protocol, which hands delivery off to PHP's built-in mail() function. On a Managed Cloud Shared Hosting account running LiteSpeed and CloudLinux, that path works unpredictably. The local MTA accepts the message, but because the envelope sender and headers are generated by the script rather than an authenticated mailbox, receiving servers at Gmail, Outlook, and Yahoo treat the message as unaligned and either quarantine it or discard it with no bounce. The application reports success, the queue looks clean, and yet nothing arrives.
The second common cause is a mismatch between the From address your CodeIgniter app uses and a mailbox that actually exists on your account. If your SPF and DKIM records authorize mail from yourdomain.com but the application sends as noreply@gmail.com or some arbitrary address, the DMARC evaluation fails outright. Shared hosting cannot sign outbound mail for a domain it does not host, so the only reliable approach is to send through an authenticated SMTP account that belongs to your own domain and is covered by your DNS records.
Both CodeIgniter 3 (the Email library) and CodeIgniter 4 (the CodeIgniter\Email\Email service) support SMTP natively. The fix is to move off mail(), point the framework at the Hostiso mail server using credentials for a mailbox you create in DirectAdmin, and confirm that your sender address matches that mailbox. Everything here is done from your unprivileged hosting account—no root, no SSH administration, no server-wide configuration.
Create a Mailbox and Configure Authenticated SMTP
Start by creating a dedicated sending mailbox so the application never shares credentials with a human inbox. In DirectAdmin Evolution, open Email Manager → E-Mail Accounts → Create Account. Use a clear local part such as app or noreply, set a strong password, and note the full address, for example app@yourdomain.com. This mailbox becomes both the SMTP login and the From address, which keeps authentication and alignment consistent.
For connection details, use your own domain's mail host (typically mail.yourdomain.com) or the server hostname shown in DirectAdmin under Email Accounts → the gear/settings icon. On Hostiso, authenticated submission uses port 587 with STARTTLS or port 465 with implicit TLS. Avoid port 25 for application submission, as outbound 25 is restricted for abuse control.
In CodeIgniter 4, edit app/Config/Email.php through the DirectAdmin File Manager (navigate to your document root, commonly domains/yourdomain.com/public_html or a subfolder holding the app). Set the properties as follows:
public string $protocol = 'smtp';
public string $SMTPHost = 'mail.yourdomain.com';
public string $SMTPUser = 'app@yourdomain.com';
public string $SMTPPass = 'your-mailbox-password';
public int $SMTPPort = 465;
public string $SMTPCrypto = 'ssl';
public string $fromEmail = 'app@yourdomain.com';
public string $fromName = 'Your Site Name';
public string $mailType = 'html';
public string $charset = 'UTF-8';
public bool $SMTPKeepAlive = true;If you prefer port 587, set $SMTPPort = 587; and $SMTPCrypto = 'tls';. For CodeIgniter 3, the equivalent lives in a config array you pass to the library, usually inside application/config/email.php:
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://mail.yourdomain.com';
$config['smtp_user'] = 'app@yourdomain.com';
$config['smtp_pass'] = 'your-mailbox-password';
$config['smtp_port'] = 465;
$config['smtp_crypto']= 'ssl';
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';
$config['newline'] = "\r\n";
$config['crlf'] = "\r\n";The newline and crlf settings in CI3 matter: many delivery failures come from the default \n, which some SMTP servers reject or mangle. Forcing \r\n keeps headers RFC-compliant. Also confirm the PHP version serving your app has the required extensions. In DirectAdmin's PHP Selector (Select PHP Version → Extensions), verify openssl is enabled, since TLS submission depends on it. Set a recent, supported PHP version under MultiPHP Manager to match what your CodeIgniter release expects.
Sender Headers, SPF, DKIM, and DMARC Alignment
Authenticated SMTP solves the transport problem; DNS alignment solves the deliverability problem. Because the mailbox lives on your Hostiso account and your domain's DNS is managed through the DirectAdmin DNS Management panel (or the Hostiso Client Portal if DNS is delegated there), you can confirm the records that let inboxes trust your mail.
Your SPF record must authorize the hosting server to send. A standard record looks like v=spf1 a mx include:yourdomain.com ~all, though Hostiso typically provisions an include or a/mx mechanism automatically. Open DNS Management and confirm a single TXT record beginning with v=spf1 exists—multiple SPF records invalidate each other. DKIM is normally enabled per domain in DirectAdmin; check Email Manager → DKIM (or confirm the default._domainkey TXT record is present under DNS Management). If DKIM is missing, enabling it through the Email Manager toggle signs outbound mail without any server-level work.
DMARC ties the two together. Add a TXT record for host _dmarc with a value such as v=DMARC1; p=none; rua=mailto:dmarc@yourdomain.com while you test, then tighten to p=quarantine once mail is landing correctly. The critical rule for CodeIgniter is that $fromEmail (CI4) or $config['from'] passed to $this->email->from() (CI3) must use the same domain that SPF and DKIM cover. If you need replies to route elsewhere, use a Reply-To header instead of changing the From address:
// CodeIgniter 4
$email = \Config\Services::email();
$email->setFrom('app@yourdomain.com', 'Your Site Name');
$email->setReplyTo('support@yourdomain.com', 'Support');
$email->setTo($user->email);
$email->setSubject('Account confirmation');
$email->setMessage($body);
if (! $email->send()) {
log_message('error', $email->printDebugger(['headers']));
}That debugger output is your best diagnostic. CodeIgniter writes it to the application log at writable/logs/log-YYYY-MM-DD.php (CI4) or application/logs/ (CI3). You can also inspect your account's error_log files via File Manager. Authentication failures appear as 535 responses, meaning the mailbox password is wrong; connection timeouts usually mean the wrong port or a crypto mismatch between ssl and tls.
Queue Handling, Throttling, and Verification
Shared hosting enforces hourly outbound message limits to protect server reputation, so a CodeIgniter app that blasts a newsletter in a single request will hit a cap and start failing midway. Rather than sending synchronously during a web request, write pending messages to a database table and process them in small batches through a cron job set up in DirectAdmin under Advanced Features → Cron Jobs. A spoke like php /home/USER/domains/yourdomain.com/public_html/spark email:process (a custom CI4 Spark command) running every few minutes lets you throttle to a safe rate and retry transient failures instead of losing them.
Keep $SMTPKeepAlive = true; when sending several messages in one run so the framework reuses a single authenticated connection rather than reconnecting per message, which is both faster and less likely to trip rate limits. Store a status and attempts column per queued message; stop retrying after a sensible threshold and log the final printDebugger() output so you can distinguish a bad recipient from a transport problem.
Before trusting the system in production, send test messages to accounts on different providers and read the raw headers. Look for spf=pass, dkim=pass, and dmarc=pass in the Authentication-Results line. If SPF passes but DKIM fails, the signature is either missing or your From domain differs from the signing domain—revisit the Email Manager DKIM toggle and your From address. If everything passes but mail still lands in spam, warm the address gradually and keep content clean, since a brand-new sending mailbox carries no reputation yet. Once headers authenticate cleanly and the queue drains without hitting the hourly cap, your CodeIgniter delivery is both reliable and trusted.