0

I needed to send an email with a PDF attached. All of this was pretty simple to do with the SnappyBundle and Swift Mailer. Whenever a call is made to ../document_name/{id}/mail a pdf is generated and the e-mail is sent.

To tried to make the user exp a little better I decided to implement the Messenger component with RabbitMQ to queue this action. But things kinda broke for Snappy at this point. This is the error I'm getting:

The exit status code '1' says something went wrong:
  stderr: "The system cannot find the path specified.
  "
  stdout: ""
  command: ..\vendor\bin\wkhtmltopdf.exe.bat --dpi "300" --image-quality 100 --page-size "A4" --footer-html "C:\Users\user\AppData\Local\Temp\knp_snappy5c8bfb5887e059.82496553.html" --header-html "C:
  \Users\user\AppData\Local\Temp\knp_snappy5c8bfb588a7c92.82567496.html" "C:\Users\user\AppData\Local\Temp\knp_snappy5c8bfb588659c2.24298174.html" "C:\Users\user\AppData\Local\Temp\knp_snappy5c8bfb
  5887d116.94779844.pdf".
  • The service that generates the pdf and then sends it works just fine whenever is not been used by the messenger:consume_messages.
  • In order to make Swift Mailer send the email as soon as I did $msg->send(); and to not spool it in memory I commented out the # spool: { type: 'memory' } on swiftmailer.yml as otherwise the email wouldn't be sent when messenger:consume_messages ran de service.

1 Answers1

0

Not sure if its intended behavior or bad practices on my side, but relative paths don't work when a service is been called by a process/command. So the solution for this was simple, instead of setting relative paths to the wkhtmltopdf executable y set an absolute one. This would look like this:

# .env.local
WKHTMLTOPDF_PATH="../vendor/bin/wkhtmltopdf.exe.bat"
# changed to:
WKHTMLTOPDF_PATH="absolute/bath/to/vendor/bin/wkhtmltopdf.exe.bat"

Hope this helps someone