0

I have the following setup/parameters:

  • PHP 7.1.26
  • Windows 10 x64 Professional
  • symfony/swiftmailer-bundle 3.5.2
  • symfony/console 4.1.11

I want to configure the swiftmailer-bundle to use the fake sendmail, which is installed at

C:\Program Files (x86)\sendmail

While I have already configured the sendmail_path in PHP, the swiftmailer-bundle does not actually use this PHP variable at all. Instead it defaults the path to the sendmail executable to

/usr/sbin/sendmail -bs

However, since version 3.0.4, the path (i.e. complete command) should be configurable: https://github.com/symfony/swiftmailer-bundle/pull/185

I put

swiftmailer:
    mailers:
        default:
            transport: sendmail
            command: 'C:\Program Files (x86)\sendmail\sendmail.exe -t'

into my app/config/config.yml and rebuilt the cache. However, when I want to send a test email via

swiftmailer:email:send

it still uses the default command - which of course fails with

[Swift_TransportException]
Process could not be started [The system cannot find the specified path.]

I am not sure what else I could try. I would really like to use the fake sendmail setup in my local environment, because sendmail can be configured to force send any email to a specific address (my address) for testing and always use a specific SMTP.

This is the output of debug:config swiftmailer:

swiftmailer:
    default_mailer: default
    mailers:
        default:
            transport: sendmail
            host: 127.0.0.1
            username: null
            password: null
            port: 25
            encryption: null
            command: 'C:\Program Files (x86)\sendmail\sendmail.exe -t'
            url: null
            timeout: 30
            source_ip: null
            local_domain: null
            auth_mode: null
            delivery_addresses: {  }
            logging: false
            delivery_whitelist: {  }
fritzmg
  • 2,494
  • 3
  • 21
  • 51
  • did you tried with double slashes: 'C:\\Program Files (x86)\\sendmail\\sendmail.exe -t' and not shure about spaces :) – myxaxa Feb 22 '19 at 14:53
  • also in the docs https://www.glob.com.au/sendmail/ there is a link to stack:) - https://stackoverflow.com/questions/21337859/sendmail-wamp-php – myxaxa Feb 22 '19 at 14:55
  • @myxaxa: no - but I did debug within the code of Swiftmailer and the config simply did not arrive at the `Swift_SendmailTransport` class. It still uses the default `/usr/sbin/sendmail -bs`. – fritzmg Feb 22 '19 at 17:46
  • @myxaxa: the Stackoverflow link only concerns the PHP configuration. The Swiftmailer Bundle does not use the PHP configuration. – fritzmg Feb 22 '19 at 17:46
  • sorry for a late response. it's weird. are you sure that there is no other config's for swiftmailer in your project? please run this command: php bin/console debug:config swiftmailer and show the output https://symfony.com/doc/current/reference/configuration/swiftmailer.html – myxaxa Mar 04 '19 at 09:38
  • Yes, I am sure there are no other configs. I have added the output of `debug:config swiftmailer` to the original post. – fritzmg Mar 04 '19 at 18:02

1 Answers1

0

update an open issue found on github: https://github.com/symfony/swiftmailer-bundle/issues/244

so it was a hard way. but try this one in your's swiftmailer.yaml:

swiftmailer:
    default_mailer: default
    mailers:
        default:
            transport: sendmail
            command: '%env(SENDMAIL_COMMAND)%'
            timeout: 20

and add a new env-variable in your .env file:

SENDMAIL_COMMAND='C:\Program Files (x86)\sendmail\sendmail.exe -t'

this was found during debuging SwiftmailerExtension.php file on line 96 you can find and if statement witch can help to understand how it works

myxaxa
  • 1,391
  • 1
  • 8
  • 7
  • Hm, seems weird. Why not directly put the command path into `swiftmailer.mailers.default.command`? What difference does it make when doing it via an environment variable? – fritzmg Mar 05 '19 at 14:58
  • I don't know - just look here - https://github.com/symfony/swiftmailer-bundle/blob/master/DependencyInjection/SwiftmailerExtension.php#L89 :) – myxaxa Mar 05 '19 at 14:59
  • only in case of env variable you'll pass the if block and use the factory to create an instance of transport and only then method setCommand of the transport is called – myxaxa Mar 05 '19 at 15:00
  • I've updated the post - found an open issue on github about all this stuff - https://github.com/symfony/swiftmailer-bundle/issues/244 :) thanks @fritzmg for this quiz! – myxaxa Mar 05 '19 at 15:19