Answer the question
In order to leave comments, you need to log in
How to send SMS using PHP in Raspbian?
I can't figure out how to send SMS using PHP.
Device: Raspberry Pi,
Axis: Raspbian,
Software: Gammu.
Sending from the command line:
gammu sendsms TEXT +79876543210 -textutf8 "Proverka"
$command = 'gammu sendsms TEXT +79509791173 -textutf8 "Proverka"';
$output = shell_exec($command);
echo "<pre>$output</pre>";
echo $output;
/* СМС не отправляет. Выводит на экран
Warning: No configuration file found!
Warning: No configuration read, using builtin defaults!
Error opening device, it doesn't exist.
Warning: No configuration file found! Warning: No configuration read, using builtin defaults! Error opening device, it doesn't exist.
*/
----------------------------------------------------------------------------------
$command = 'sudo gammu sendsms TEXT +79509791173 -textutf8 "Proverka"';
$output = shell_exec($command);
echo "<pre>$output</pre>";
echo $output;
/* СМС не отправляет. Ничего не выводит */
----------------------------------------------------------------------------------
$command = 'sudo /usr/bin/gammu sendsms TEXT +79509791173 -textutf8 "Proverka"';
$output = shell_exec($command);
echo "<pre>$output</pre>";
echo $output;
/* СМС не отправляет. Ничего не выводит */
Answer the question
In order to leave comments, you need to log in
Perhaps the permissions on the configuration file are set incorrectly and when running from php it is impossible to read it
You have clearly been told what the error is:
And it works from the command line, because the environment variables (including HOME, in which the configs are located) are from your user, and not www-data.
Either specify for gammu even before the configuration file (if it understands this), or specify everything that it needs (port device name, port parameters, etc.) when calling gammu.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question