Laminas\Mail\Protocol\Exception\RuntimeException error

These are lines which I edited to configure the smtp settings from settings.php. Something must be wrong that sending mesages or liking a post causes error "Laminas\Mail\Protocol\Exception\RuntimeException". 

---

/**
 * Configure emailer transport
 *
 * This setting can be used to select a different emailer transport. By default the Laminas Sendmail Transport is used.
 * Currently only 'smtp' and 'sendmail' are supported as a different configuration.
 * For 'smtp', the SMTP server's settings must be set, while 'sendmail' requires no configuration.
 *
 * @global string $CONFIG->emailer_transport
 */

$CONFIG->emailer_transport = 'smtp';

/**
 * Configure sendmail related settings
 */

$CONFIG->emailer_sendmail_settings = 'smtp';

/**
 * Configure emailer SMTP settings
 *
 * This setting is only necessary if the above emailer transport is set to 'smtp'.
 * Please refer to https://docs.laminas.dev/laminas-mail/transport/smtp-options/#configuration-options
 * and https://docs.laminas.dev/laminas-mail/transport/smtp-authentication/#examples
 */

$CONFIG->emailer_smtp_settings = array(
// 'name'              => 'localhost.localdomain',
'host'              => 'ni-chrome.guzelhosting.com',
'port'              => 465,
'connection_class'  => 'login',
'connection_config' => [
'username' => 'noreply@ahalim.com',
'password' => '*******',
'ssl'      => 'tls', // OPTIONAL (tls or ssl)
'port'     => '587', // OPTIONAL (Non-SSL default 25, SSL default 465, TLS default 587)
// 'use_complete_quit' => '', // OPTIONAL
],
);

---

My coding experience is poor.  I need your help. The error log belong this is below

Laminas\Mail\Protocol\Exception\RuntimeException: Could not read from ni-chrome.guzelhosting.com in .../.../ahalim.com/vendor/laminas/laminas-mail/src/Protocol/AbstractProtocol.php:298

Stack trace:

#0 .../.../ahalim.com/vendor/laminas/laminas-mail/src/Protocol/AbstractProtocol.php(326): Laminas\Mail\Protocol\AbstractProtocol->_receive(300)

#1 .../.../ahalim.com/vendor/laminas/laminas-mail/src/Protocol/Smtp.php(277): Laminas\Mail\Protocol\AbstractProtocol->_expect(Array, 300)

#2 .../.../ahalim.com/vendor/laminas/laminas-mail/src/Transport/Smtp.php(396): Laminas\Mail\Protocol\Smtp->helo('localhost')

#3 .../.../ahalim.com/vendor/laminas/laminas-mail/src/Transport/Smtp.php(378): Laminas\Mail\Transport\Smtp->connect()

#4 .../.../ahalim.com/vendor/laminas/laminas-mail/src/Transport/Smtp.php(389): Laminas\Mail\Transport\Smtp->lazyLoadConnection()

  • Don't you have any idea to overcome the issue?

  • I have limited experience with the smtp settings.

    • Make sure the hostname is correct
    • make sure there is no firewall preventing outgoing connections on port 465 & 587
  • Jerome, The hostname in the code is the one which my hosting server sent me in an e-mail. I just copied and pasted from the mail. So there musn't be any mistake on hosting name. The port is also the one they sent.

    But I don't know if their system has a firewall preventing outgoing connections on port 465 & 58. I will write them.

  • The support center sent me the message "

    A sample SMTP file has been added to https://ahalim.com/smtptest/gonder.php by defining your sMTP information, and when tested, successful transmission can be achieved.
     
    If you can activate the debug feature in the software on the SMTP side, it will give a clearer output about the problem."
     
    When I cllick the link "https://ahalim.com/smtptest/gonder.php" I see really it works from the lines below:
    2023-11-28 14:29:17 Connection: opening to ni-chrome.guzelhosting.com:587, timeout=300, options=array()
    2023-11-28 14:29:17 Connection: opened
    2023-11-28 14:29:17 SERVER -> CLIENT: 220-ni-chrome.guzelhosting.com ESMTP Exim 4.96.2 #2 Tue, 28 Nov 2023 17:29:17 +0300 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail.
    2023-11-28 14:29:17 CLIENT -> SERVER: EHLO ahalim.com
    2023-11-28 14:29:17 SERVER -> CLIENT: 250-ni-chrome.guzelhosting.com Hello ahalim.com [89.252.159.194]250-SIZE 52428800250-8BITMIME250-PIPELINING250-PIPECONNECT250-AUTH PLAIN LOGIN250-STARTTLS250 HELP
    2023-11-28 14:29:17 CLIENT -> SERVER: STARTTLS
    2023-11-28 14:29:17 SERVER -> CLIENT: 220 TLS go ahead
    2023-11-28 14:29:17 CLIENT -> SERVER: EHLO ahalim.com
    2023-11-28 14:29:17 SERVER -> CLIENT: 250-ni-chrome.guzelhosting.com Hello ahalim.com [89.252.159.194]250-SIZE 52428800250-8BITMIME250-PIPELINING250-PIPECONNECT250-AUTH PLAIN LOGIN250 HELP
    2023-11-28 14:29:17 CLIENT -> SERVER: AUTH LOGIN
    2023-11-28 14:29:17 SERVER -> CLIENT: 334 VXNlcm5hbWU6
    2023-11-28 14:29:17 CLIENT -> SERVER: <credentials hidden>
    2023-11-28 14:29:17 SERVER -> CLIENT: 334 UGFzc3dvcmQ6
    2023-11-28 14:29:17 CLIENT -> SERVER: <credentials hidden>
    2023-11-28 14:29:17 SERVER -> CLIENT: 235 Authentication succeeded
    2023-11-28 14:29:17 CLIENT -> SERVER: MAIL FROM:<noreply@ahalim.com>
    2023-11-28 14:29:17 SERVER -> CLIENT: 250 OK
    2023-11-28 14:29:17 CLIENT -> SERVER: RCPT TO:<gnettestmail1@gmail.com>
    2023-11-28 14:29:17 SERVER -> CLIENT: 250 Accepted
    2023-11-28 14:29:17 CLIENT -> SERVER: DATA
    2023-11-28 14:29:17 SERVER -> CLIENT: 354 Enter message, ending with "." on a line by itself
    2023-11-28 14:29:17 CLIENT -> SERVER: Date: Tue, 28 Nov 2023 17:29:17 +0300
    2023-11-28 14:29:17 CLIENT -> SERVER: To: gnettestmail1@gmail.com
    2023-11-28 14:29:17 CLIENT -> SERVER: From: Mailer <noreply@ahalim.com>
    2023-11-28 14:29:17 CLIENT -> SERVER: Reply-To: Information <gnettestmail1@gmail.com>
    2023-11-28 14:29:17 CLIENT -> SERVER: Subject: Here is the subject
    2023-11-28 14:29:17 CLIENT -> SERVER: Message-ID: <ser9m5qywymrm0B3r4ei20A75AWGHbfneA2Z8Csfgmg@ahalim.com>
    2023-11-28 14:29:17 CLIENT -> SERVER: X-Mailer: PHPMailer 6.0.7 (https://github.com/PHPMailer/PHPMailer)
    2023-11-28 14:29:17 CLIENT -> SERVER: MIME-Version: 1.0
    2023-11-28 14:29:17 CLIENT -> SERVER: Content-Type: multipart/alternative;
    2023-11-28 14:29:17 CLIENT -> SERVER: boundary="b1_ser9m5qywymrm0B3r4ei20A75AWGHbfneA2Z8Csfgmg"
    2023-11-28 14:29:17 CLIENT -> SERVER: Content-Transfer-Encoding: 8bit
    2023-11-28 14:29:17 CLIENT -> SERVER:
    2023-11-28 14:29:17 CLIENT -> SERVER: This is a multi-part message in MIME format.
    2023-11-28 14:29:17 CLIENT -> SERVER: --b1_ser9m5qywymrm0B3r4ei20A75AWGHbfneA2Z8Csfgmg
    2023-11-28 14:29:17 CLIENT -> SERVER: Content-Type: text/plain; charset=us-ascii
    2023-11-28 14:29:17 CLIENT -> SERVER:
    2023-11-28 14:29:17 CLIENT -> SERVER: This is the body in plain text for non-HTML mail clients
    2023-11-28 14:29:17 CLIENT -> SERVER:
    2023-11-28 14:29:17 CLIENT -> SERVER: --b1_ser9m5qywymrm0B3r4ei20A75AWGHbfneA2Z8Csfgmg
    2023-11-28 14:29:17 CLIENT -> SERVER: Content-Type: text/html; charset=us-ascii
    2023-11-28 14:29:17 CLIENT -> SERVER:
    2023-11-28 14:29:17 CLIENT -> SERVER: This is the HTML message body <b>in bold!</b>
    2023-11-28 14:29:17 CLIENT -> SERVER:
    2023-11-28 14:29:17 CLIENT -> SERVER:
    2023-11-28 14:29:17 CLIENT -> SERVER: --b1_ser9m5qywymrm0B3r4ei20A75AWGHbfneA2Z8Csfgmg--
    2023-11-28 14:29:17 CLIENT -> SERVER:
    2023-11-28 14:29:17 CLIENT -> SERVER: .
    2023-11-28 14:29:17 SERVER -> CLIENT: 250 OK id=1r7z5R-0000He-21
    2023-11-28 14:29:17 CLIENT -> SERVER: QUIT
    2023-11-28 14:29:17 SERVER -> CLIENT: 221 ni-chrome.guzelhosting.com closing connection
    2023-11-28 14:29:17 Connection: closed
    Message has been sent
     
    So why does it display "Laminas\Mail\Protocol\Exception\RuntimeException" when I try to like someone else's post in my elgg? But, then,  when I refresh the page the post looks liked. Does it mean a bug?
    One more thing, this doesn't happen when I try to like one of my own prevous post! Only while clicking on "like" for others' post, it occurs.
  • @Fazil

    In your settings you specified the "port" parameter twice

  • Nikolai,

    The first value for the port just after "host" was mistakenly typed as "465" here,  in fact it is   also "587" in "settings.php"  like the second port value.

    In the file "settings.php" the value for the port mentioned   just after "ssl" is defined as"optional". 
    Does it mean that we should close this line using "//"? Or should we keep it without "//" it for "'ssl'      => 'tls'" value?
  • Your config is incorrect. Here're the correct settings:

    $CONFIG->emailer_transport = 'smtp';
    
    // $CONFIG->emailer_sendmail_settings = '';
    
    $CONFIG->emailer_smtp_settings = array(
        'name'              => 'localhost.localdomain',
        'host'              => 'ni-chrome.guzelhosting.com',
        //'port'              => 25,
        'connection_class'  => 'login',
        'connection_config' => [
            'username' => 'user',
            'password' => 'pass',
            'ssl'      => 'tls',
            'port'     => '587',
             //'use_complete_quit' => '',
        ],
    );
    Related discussions 1, 2, 3
  • I was wrong in the previuos post. Here's the corrected version:

    $CONFIG->emailer_transport = 'smtp';
    
    // $CONFIG->emailer_sendmail_settings = '';
    
    $CONFIG->emailer_smtp_settings = array(
        'name'              => 'localhost.localdomain',
        'host'              => 'ni-chrome.guzelhosting.com',
        'port'              => 25,
        'connection_class'  => 'login',
        'connection_config' => [
            'username' => 'user',
            'password' => 'pass',
            'ssl'      => 'tls',
            'port'     => '587',
             //'use_complete_quit' => '',
        ],
    );

    You shouldn't comment out the default port (25)

  • Thanks Nikolai,

    Your sample settings above made me clear. I reedited the settings. And also I realised that the email address in settings in administration page (Site email address (used when sending system emails))  is different than I used in settings.php to set the smtp.

    Now it works properly. Thanks for your helps. And I'm sorry for my carelessness which made here a bit busy.

  • Hi Nikolai,

    We are back to square one with the problem "Laminas\Mail\Protocol\Exception\RuntimeException" again. 

    After upgrading to 5.1.8, Creating a new user or liking a post produce the error "Laminas\Mail\Protocol\Exception\RuntimeException" again

    And when I check settings.php, the related lines are exactly same with yours. The username and password are correct.

    I wonder if there might be another solution, may be a plugin?, to overcome the issue.

     

    Another problem is that I can't check the errol log. It produces "Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 2539520 bytes) in /home/buradan4/ahalim.com/vendor/elgg/elgg/views/default/page/components/module.php on line 58"

    In 4x. it used to produce  "Invalid admin section".

    My elgg v5.1.8 (Upgraded from 4x. to 5.1.8)

    Php version 8.2.21

     

    Any ide to overcome the issue? Thanks for now.