So, for one reason or another, I can't use the mail() PHP function and neither PHPMailer with SMTP. So looking for options, I wrote a short shell script to send an email with an attachment, as follows:
#!/bin/bash
echo "Some text $1 $2 $3" | mail -a "/path/to/attached/file.xlsx" -s "Subject text" some@email.com
When I run the file directly from the terminal, it works perfectly and the mail is correctly received with the attachment and all.
But when I try to run from PHP, I have the following code:
shell_exec("bash /path/to/script $m1t $m2t $afl");
And it doesn't show any error and doesn't return any output, yet the mail is not sent.
Can't I make a shell script send emails by calling it through PHP? Or am I doing something wrong?
Appreciate any help on the matter.