CodeIgniter Forums
SMTP throwing certificate error - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: SMTP throwing certificate error (/showthread.php?tid=92424)



SMTP throwing certificate error - yogisrini - 02-03-2025

Hi,
We migrated from php 5 to 7 post that we see the SMTP flow is not stable tried importing the certificate in the truststore but post that the email flow is inconsistent works sometime but fails with junk characters. The error message is not very clear on why its failing. Have masked some of the data for security reason.
Please see if there is a way to identify the issue or debug it.

Code:
function send_smtp($dest, $subject, $message, $smtp = NULL) {
        if (!$smtp) {
            $smtp = $this->make_smtp(false);
        }
        $config = array(
            'protocol' => 'smtp',
            'smtp_host' => $smtp['server'],
            'smtp_port' => $smtp['port'],
            'useragent' => "NexthinkAppliance",
            'mailtype'  => "html",
            'newline'  => "\r\n",
            'crlf'      => "\r\n"
        );
        if (strlen($smtp['login']) > 0) {
            $config['smtp_user'] = $smtp['login'];
        }
        if (strlen($smtp['password']) > 0) {
            $config['smtp_pass'] = $smtp['password'];
        }
        if ($smtp['tls'] === 'true') {
            $config['smtp_crypto'] = 'tls';
        }
        $this->load->library('email', $config);
        $this->email->from($smtp['from']);
        $this->email->to($dest);
        $this->email->subject($subject);
        $this->email->message($message);
        if (!$this->email->send()) {
            log_message('debug', $this->email->print_debugger());
            throw new Exception("Unable to send email. Check parameters");
        }
        log_message('debug', $this->email->print_debugger());
    }
---------------
INFO - 2025-01-21 07:39:13 --> Email Class Initialized
INFO - 2025-01-21 07:39:18 --> Language file loaded: language/english/email_lang.php
DEBUG - 2025-01-21 07:39:28 --> <br /><pre>hello: 220 Authentication required
</pre>The following SMTP error was encountered: 220 Authentication required
<br /><pre>starttls: 250-SI-EXCAS2000.xx.yyyy.com Hello [xx.yyy.zzz.nnn]
250-SIZE 36700160
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-8BITMIME
250-BINARYMIME
250 CHUNKING
</pre>The following SMTP error was encountered: 250-SI-EXCAS2000.xx.yyyy.com Hello [xx.yyy.zzz.nnn]
250-SIZE 36700160
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-8BITMIME
250-BINARYMIME
250 CHUNKING
<br />The following SMTP error was encountered: .0.0 SMTP server ready

..........Mix of encoded characters that cannot be pasted...............

<br />Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.<br /><pre>Date: Tue, 21 Jan 2025 07:39:13 +0000
From: &lt;[email protected]&gt;
Return-Path: &lt;[email protected]&gt;
To: [email protected], [email protected]
Subject: =?UTF-8?Q?[abcd=20appliance]=20test=20email?=
Reply-To: &lt;[email protected]&gt;
User-Agent: abcdAppliance
X-Sender: [email protected]
X-Mailer: abcdAppliance
X-Priority: 3 (Normal)
Message-ID: &lt;[email protected]&gt;
Mime-Version: 1.0


Content-Type: multipart/alternative; boundary=&quot;B_ALT_678f4f2127b21&quot;

This is a multi-part message in MIME format.
Your email application may not support this format.

--B_ALT_678f4f2127b21
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This email has been sent from the abcd configuration console hosted on:
si0nxqa01.de.yyyy.com


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

=0A&lt;html&gt;=0A    &lt;head&gt;=0A        &lt;title&gt;abcd Appliance&lt;/title&gt;=0A    &lt;/=
head&gt;=0A    &lt;body&gt;=0A        This email has been sent from the abcd con=
figuration console hosted on: si0nxqa01.de.yyyy.com&lt;br/&gt;=0A    &lt;/body&gt;=0A&lt;=
/html&gt;

--B_ALT_678f4f2127b21--</pre>

}