symfonyswiftmailercontao

Contao > 4.3 sending emails with sendmail throw error on some providers


Older Versions of Contao (till 4.3) working like expected with sending emails via sendmail. After upgrade to Contao 4.9 I got some errors at Providers like 1u1 / ionos or mittwald.

The error in the logs sound like:

"Expected response code 220 but got an empty response"

Sending Mails from CLI of the Server (means if logged in via SSH) working like expected:sendmail test" |

/usr/sbin/sendmail -t -v -f sender@domain.com reciepient@otherOne.com


Solution

  • The solution is to add this to config/config.yml

    swiftmailer:
      default_mailer: default
      mailers:
        default:
          url: '%env(MAILER_URL)%'
          transport: sendmail
          command: '/usr/sbin/sendmail -t -i'
    

    After that, clear the Contao-Cache (e.g. via contao-manager.phar) and give it a try.

    The reason for that issue is, that by default the swiftMailer use sendmail -bs as command, which means that sendmail run as standalone Service. Depending at the way your provider configure it's sendmail, this will be the cause of the error.