Problems with SMTP Server config

Your software
My Mautic version is: 4.0.1
My PHP version is: 8.0.11
My Database type and version is: mysql 8.0.26

Your problem
My problem is:
I’m a newcomer. I recieve only garbled mails without content or no mail. I tried it with “Other SMPT Server” and Sendmail. For Sendmail i use msmtp and it’s working with pure php
php -r “mail(‘reciever@testmail.example’,‘Test Mail from PHP’, ‘This is a test mail from PHP, let me know if this works’);”
Also the Testmail from the Configuration is working. The server is in a closed network, only with proxy for internet access. So I also interested in image to base64 conversation, because the reciever need a vpn connect, to get access to the server and also to linked images.

These errors are showing in the log:
msmtp.log show only the manual test’s with command line
with Image to base64 active, I got the error from apache
mautic.ERROR: [MAIL ERROR] Unable to open file for reading
var/logs/mautic_prod-2021-10-15.php
mautic.ERROR: An error occurred while attempting to fetch the language list: cURL error 56: Received HTTP code 403 from proxy after CONNECT (see libcurl - Error Codes) for https://language-packs.mautic.com/manifest.json

Steps I have tried to fix the problem: I tried several configuration with smtp server. I didn’t find any useful debug information for the mail, so i don’t have an ideas what i could do. I didn’t find alike problem with a closed network.

this looks like it may be a permission problem

  1. Are you running your cronjob as www-data
  2. Go ahead and chown -R www-data:www-data on your entire mautic directory
  1. i don’t have cronjobs with this first test. There are only 5 Testemails
  2. Done, although this was not the problem.

but with yout hint bring me to the real problem, the dns…the server didn’t know his own Domain Name, so swiftmailer can’t find the picture, because the domain is unknown. A little hosts Update solved the problem with the pictures.

 cat /etc/hosts
127.0.0.1       localhost
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
127.0.0.1       webserver.example.de

But now i have a problem with TLS

[2021-10-20 09:25:08] mautic.WARNING: PHP Warning - stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed - in file /var/www/html/mautic4/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php - at line 94 [] []

[2021-10-20 09:25:08] mautic.ERROR: [MAIL ERROR] Unable to connect with TLS encryption Log data: ++ Starting Swift_Transport_EsmtpTransport << 220 smtp.example.local ESMTP Postfix >> EHLO webserver.example.de << 250-smtp.example.local 250-PIPELINING 250-SIZE 104857600 250-VRFY 250-ETRN 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-8BITMIME 250-DSN 250 CHUNKING >> STARTTLS << 220 2.0.0 Ready to start TLS !! Unable to connect with TLS encryption (code: 0) (send); testuser@email.local {"exception":"[object] (Swift_TransportException(code: 0): Unable to connect with TLS encryption\nLog data:\n++ Starting Swift_Transport_EsmtpTransport\n<< 220 smtp.example.local ESMTP Postfix\r\n\n>> EHLO webserver.example.de\r\n\n<< 250-smtp.example.local\r\n250-PIPELINING\r\n250-SIZE 104857600\r\n250-VRFY\r\n250-ETRN\r\n250-STARTTLS\r\n250-ENHANCEDSTATUSCODES\r\n250-8BITMIME\r\n250-DSN\r\n250 CHUNKING\r\n\n>> STARTTLS\r\n\n<< 220 2.0.0 Ready to start TLS\r\n\n!! Unable to connect with TLS encryption (code: 0) at /var/www/html/mautic4/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/LoggerPlugin.php:124)"} []

i have a ca-certificate for the smtp server, stored is /etc/ssl/certs/, this should be working ? Can I specify a special ca-file in the config ?

i don’t know why it didn’t choose the right pem file, like before, but you can choose it by yourself with the enviroment variable “set SSL_CERT_FILE=/etc/ssl/certs/TRUST-ME-CA_2021.pem

you can check the exchange with

openssl s_client -connect smtp.server.local:587 -starttls smtp

optional with --CApath or --CAfile

the verifivation part must be ok

SSL handshake has read 5200 bytes and written 464 bytes
Verification: OK

not:

SSL handshake has read 5200 bytes and written 464 bytes
Verification error: self signed certificate in certificate chain

with this it’s working. It’s a little bit special, but maybe it helps somebody else in a same situation