mjml-bundle: Can't make it work with symfony on the same docker container
I’m working on a symfony project on docker container and i set up a Mailer service.I installed binaries on the container with npm install mjml
. In the code :
$mail = new \Swift_Message();
$mail
->setFrom($from)
->setTo($to)
->setSubject($subject)
->setBody($body)
->setContentType('text/mjml');
$this->mailer->send($mail);
The thing is that when i request the function which send the mail via the docker container, there is no error but it does not send the mail. But when i start a server with php -S adress -t public
and i request the function which send the mail, the mail is sent.In the log for the container there is could not found mjml binary
but when i enter in the container the mjml command works
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 17 (9 by maintainers)
not sure if this problem relate here, I did not use docker but I bumped here when facing following problem. Hope it help someone (and maybe code modif suggestion below?)
Mac Catalina 10.15.4 Symfony 5.1
Problem Running these lines work well on CLI
Check my config :
BUT when accessing url (e.g localhost/send-email)
Yeah I know the
mjml
path is different from the config coz I reinstall it usingnpm install -global mjml
Please read below on ‘Try 2’Looking at the error, I figured the error happened here BinaryRenderer::getMjmlVersion()
In search of solution : Try 1 Put this line right above $process = new Process
putenv('PATH='.$path.':/usr/local/bin');
var_dump-ing it produces ‘PATH’ => ‘/usr/bin:/bin:/usr/sbin:/sbin’ on browser screen (different from
echo $PATH
run in Terminal)Try 2 Look for
node
andmjml
binary in /usr/local/bin , /usr/bin but did not find any. Not sure if this affect anything : uninstall mjml then install it using-global
Then, tried to create symlink ofnode
to /usr/binBut
Operation not permitted
(apple…)Try 3 Tried to put env var here
/System/Library/LaunchDaemons/org.apache.httpd.plist
but again, Catalina put this as read onlyDoing
csrutil disable
does not resolve the issue. I could not change the file, nor create symlink 😦Last Resort No choice, I have to modify the code. Please let me know if this is not at all best practice but this has helped me
(Worth to note that the problem above does NOT happen in CentOS 7)
BinaryRenderer
Configuration
MJMLExtension
So now I could have full path of
node
like so : mjml.yamlSame issue : https://stackoverflow.com/questions/59004529/run-mjml-cli-using-symfony-process