Setting up a SMTP connection

Hello,

We are trying to configure our Omeka to send email messages through and we have asked our IT department to activate the smtp functionality on the same server that Omeka sits on.

We have tried the following configuration in our config.ini file based on the Omeka guide

'mail' => [
        'transport' => [
            'type' => 'smtp',
            'options' => [
                'name' => 'localhost',
                'host' => '127.0.0.1',
                'port' => 25, // 465 for 'ssl', and 587 for 'tls'
                'connection_class' => 'plain', // 'plain', 'login', or 'crammd5'
                'connection_config' => [
                    'username' => null,
                    'password' => null,
                    'ssl' => null, // 'ssl' or 'tls'
                    'use_complete_quit' => true,
                ],
            ],
        ],
    ],

However, I am still getting two errors:

Laminas\Mail\Protocol\Exception\RuntimeException: Could not open socket: stream_socket_client(): unable to connect to tcp://127.0.0.1:25 (Connection refused) in /data/www/omeka-s/vendor/laminas/laminas-mail/src/Protocol/AbstractProtocol.php:210
Stack trace:
#0 [internal function]: Laminas\Mail\Protocol\AbstractProtocol->Laminas\Mail\Protocol\{closure}(2, 'stream_socket_c...', '/data/www/omeka...', 214, Array)
#1 /data/www/omeka-s/vendor/laminas/laminas-mail/src/Protocol/AbstractProtocol.php(214): stream_socket_client('tcp://127.0.0.1...', 111, 'Connection refu...', 30)
#2 /data/www/omeka-s/vendor/laminas/laminas-mail/src/Protocol/Smtp.php(186): Laminas\Mail\Protocol\AbstractProtocol->_connect('tcp://127.0.0.1...')
#3 /data/www/omeka-s/vendor/laminas/laminas-mail/src/Transport/Smtp.php(398): Laminas\Mail\Protocol\Smtp->connect()
#4 /data/www/omeka-s/vendor/laminas/laminas-mail/src/Transport/Smtp.php(384): Laminas\Mail\Transport\Smtp->connect()
#5 /data/www/omeka-s/vendor/laminas/laminas-mail/src/Transport/Smtp.php(395): Laminas\Mail\Transport\Smtp->lazyLoadConnection()
#6 /data/www/omeka-s/vendor/laminas/laminas-mail/src/Transport/Smtp.php(252): Laminas\Mail\Transport\Smtp->connect()
#7 /data/www/omeka-s/application/src/Stdlib/Mailer.php(86): Laminas\Mail\Transport\Smtp->send(Object(Laminas\Mail\Message))
#8 /data/www/omeka-s/application/src/Stdlib/Mailer.php(197): Omeka\Stdlib\Mailer->send(Object(Laminas\Mail\Message))
#9 /data/www/omeka-s/application/src/Controller/LoginController.php(166): Omeka\Stdlib\Mailer->sendResetPassword(Object(Omeka\Entity\User))
#10 /data/www/omeka-s/vendor/laminas/laminas-mvc/src/Controller/AbstractActionController.php(77): Omeka\Controller\LoginController->forgotPasswordAction()
#11 /data/www/omeka-s/vendor/laminas/laminas-eventmanager/src/EventManager.php(321): Laminas\Mvc\Controller\AbstractActionController->onDispatch(Object(Laminas\Mvc\MvcEvent))
#12 /data/www/omeka-s/vendor/laminas/laminas-eventmanager/src/EventManager.php(178): Laminas\EventManager\EventManager->triggerListeners(Object(Laminas\Mvc\MvcEvent), Object(Closure))
#13 /data/www/omeka-s/vendor/laminas/laminas-mvc/src/Controller/AbstractController.php(105): Laminas\EventManager\EventManager->triggerEventUntil(Object(Closure), Object(Laminas\Mvc\MvcEvent))
#14 /data/www/omeka-s/vendor/laminas/laminas-mvc/src/DispatchListener.php(139): Laminas\Mvc\Controller\AbstractController->dispatch(Object(Laminas\Http\PhpEnvironment\Request), Object(Laminas\Http\PhpEnvironment\Response))
#15 /data/www/omeka-s/vendor/laminas/laminas-eventmanager/src/EventManager.php(321): Laminas\Mvc\DispatchListener->onDispatch(Object(Laminas\Mvc\MvcEvent))
#16 /data/www/omeka-s/vendor/laminas/laminas-eventmanager/src/EventManager.php(178): Laminas\EventManager\EventManager->triggerListeners(Object(Laminas\Mvc\MvcEvent), Object(Closure))
#17 /data/www/omeka-s/vendor/laminas/laminas-mvc/src/Application.php(331): Laminas\EventManager\EventManager->triggerEventUntil(Object(Closure), Object(Laminas\Mvc\MvcEvent))
#18 /data/www/omeka-s/index.php(21): Laminas\Mvc\Application->run()
#19 {main}

and

Laminas\Mail\Protocol\Exception\RuntimeException: Could not open socket: preg_match(): No ending delimiter '/' found in /data/www/omeka-s/vendor/laminas/laminas-mail/src/Protocol/AbstractProtocol.php:210
Stack trace:
#0 [internal function]: Laminas\Mail\Protocol\AbstractProtocol->Laminas\Mail\Protocol\{closure}(2, 'preg_match(): N...', '/data/www/omeka...', 224, Array)
#1 /data/www/omeka-s/modules/GoogleAnalytics/Module.php(224): preg_match('/^[G][-]\\w*', 'G-XJSV46VXNB')
#2 /data/www/omeka-s/vendor/laminas/laminas-eventmanager/src/EventManager.php(321): GoogleAnalytics\Module->printScript(Object(Laminas\EventManager\Event))
#3 /data/www/omeka-s/vendor/laminas/laminas-eventmanager/src/EventManager.php(170): Laminas\EventManager\EventManager->triggerListeners(Object(Laminas\EventManager\Event))
#4 /data/www/omeka-s/application/src/View/Helper/Trigger.php(61): Laminas\EventManager\EventManager->triggerEvent(Object(Laminas\EventManager\Event))
#5 [internal function]: Omeka\View\Helper\Trigger->__invoke('view.layout')
#6 /data/www/omeka-s/vendor/laminas/laminas-view/src/Renderer/PhpRenderer.php(396): call_user_func_array(Object(Omeka\View\Helper\Trigger), Array)
#7 /data/www/omeka-s/application/view/layout/layout.phtml(11): Laminas\View\Renderer\PhpRenderer->__call('trigger', Array)
#8 /data/www/omeka-s/vendor/laminas/laminas-view/src/Renderer/PhpRenderer.php(505): include('/data/www/omeka...')
#9 /data/www/omeka-s/vendor/laminas/laminas-view/src/View.php(206): Laminas\View\Renderer\PhpRenderer->render(NULL)
#10 /data/www/omeka-s/vendor/laminas/laminas-mvc/src/View/Http/DefaultRenderingStrategy.php(104): Laminas\View\View->render(Object(Laminas\View\Model\ViewModel))
#11 /data/www/omeka-s/vendor/laminas/laminas-eventmanager/src/EventManager.php(321): Laminas\Mvc\View\Http\DefaultRenderingStrategy->render(Object(Laminas\Mvc\MvcEvent))
#12 /data/www/omeka-s/vendor/laminas/laminas-eventmanager/src/EventManager.php(170): Laminas\EventManager\EventManager->triggerListeners(Object(Laminas\Mvc\MvcEvent))
#13 /data/www/omeka-s/vendor/laminas/laminas-mvc/src/Application.php(366): Laminas\EventManager\EventManager->triggerEvent(Object(Laminas\Mvc\MvcEvent))
#14 /data/www/omeka-s/vendor/laminas/laminas-mvc/src/Application.php(347): Laminas\Mvc\Application->completeRequest(Object(Laminas\Mvc\MvcEvent))
#15 /data/www/omeka-s/index.php(21): Laminas\Mvc\Application->run()
#16 {main}

Would you have any suggestions for how to fix? Many thanks,
Sanjin

This just means that there’s no SMTP server running on the local server, or it’s not accepting connections. For mail servers running on the same server, it’s more typical to use the default “Sendmail” mail setup (so, no mail configuration in the config.ini file) rather than SMTP. Maybe that’s your problem?

Thanks @jflatnes, your advice helped us “send” the mail from Omeka S, but now we are just dealing with our internal institutional settings which seem to block the mail from coming to inboxes. As Admin I am getting emails saying that the email could not be delivered.

Remote Server returned '554 5.1.1 <za-smtp-inbound-2.mimecast.co.za #5.1.1 SMTP; 550 Anti-Spoofing policy - Inbound not allowed - https://community.mimecast.com/docs/DOC-1369#550

Remote Server returned ‘554 5.7.0 <gmail-smtp-in.l.google.com #5.7.26 SMTP; 550-5.7.26 Unauthenticated email from uct.ac.za is not accepted due to domain’s>’

Thanks for getting us to this point!