Skip to main content

Setting up the mail configuration in October CMS is a quick progress.  Depending on which mail method you use there are up to eight fields to complete:

  • Sender name;
  • Sender email;
  • Mail method: (PHP mail, Sendmail, SMTP, etc...).  I elected to go with SMTP; 
  • SMTP address - such as smtp.your-domain.com or mail.your-domain.com;
  • SMTP port - 587;
  • SMTP encryption protocol - TLS or SSL;
  • Authorization required - boolean response;
  • Username - email account; and
  • Password - respective email password

In configuring these variables, I was hopeful that the connection would be seamless.  But no it wouldn't be so simple!

 

Errors

SSL operation failed with code 1
stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed

To resolve this error, you need to edit you mail.php file in the config directory.  Open the file using vi command

vi config/mail.php

Scroll to the bottom where that last batch of lines are:

/*
    |--------------------------------------------------------------------------
    | Sendmail System Path
    |--------------------------------------------------------------------------
    |
    | When using the "sendmail" driver to send e-mails, we will need to know
    | the path to where Sendmail lives on this server. A default path has
    | been provided here, which will work well on most of your systems.
    |
    */

    'sendmail' => '/usr/sbin/sendmail -bs',

];

After the 'sendmail' => '/usr/sbin/sendmail -bs', add the following

    'stream' => [
        'ssl' => [
            'allow_self_signed' => true,
            'verify_peer' => false,
            'verify_peer_name' => false,
        ],
    ],

So it now becomes

 /*
    |--------------------------------------------------------------------------
    | Sendmail System Path
    |--------------------------------------------------------------------------
    |
    | When using the "sendmail" driver to send e-mails, we will need to know
    | the path to where Sendmail lives on this server. A default path has
    | been provided here, which will work well on most of your systems.
    |
    */

    'sendmail' => '/usr/sbin/sendmail -bs',

    'stream' => [
        'ssl' => [
            'allow_self_signed' => true,
            'verify_peer' => false,
            'verify_peer_name' => false,
        ],
    ],

];

Save using esc:wq! command

Go back to your October CMS backend and test the mail function again.  If like us, your mail will be working correctly now.

 

Wrong mail server configuration
Connection could not be established with host smtp.your-domain.com :stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Name or service not known

If the SMTP address is incorrect you will receive the above error.  In this instance I attempt tried smtp.your-domain.com.  While this failed, at least I knew how come.  In my situation, I tested

  • your-domain.com
  • smtp.your-domain.com
  • mail.your-domain.com

mail.your-domain.com was the only successful SMTP.  Which was a little surprising as the email clients SMTP server had been configured to your-domain.com.

 

Wrong encryption protocol 

Connection could not be established with host your-domain.com :stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

In this instance I tested changing the SMTP encryption protocol from TLS to SSL.  In doing so, the error above came to live.  Switching back to TLS and the error had gone.  Note that on the server I had also set up TLS.
 

Related articles

Andrew Fletcher13 Feb 2021
Twig using set to determine if a loop.index is odd or even
Working in Laravel, I needed to loop through an array and know whether the current loop was odd or even row.  To do this add the expression to your Twig file: {% set direction = loop.index0 is odd ? 'left' : 'right' %} In the call above, the variable direction is set to either left...
Andrew Fletcher11 Nov 2020
OctoberCMS common command functions
Common commands Themes and plugins have similar command lines.  So rather than note them individually and miss clarity, the reference {type} can be replaced with the term plugin or theme.   install php artisan {type}:install...
Andrew Fletcher14 Oct 2020
clearing cache
At times while developing in October CMS, you will perform a step that kills the site.  Recently, I had transferred the site to production and I was working through our steps to cross check deployment.  This included reviewing the error logger plugin.  The error logger has four tabs...