StephanK
(Stephan Koenig)
December 1, 2016, 8:28pm
1
I am working on a little addon to send an e-mail notification once a text message comes in. I am a developer, but I have never worked with PHP.
I get the body of a text with
$AGI = new AGI();
$body2 = trim($argv[2]);
and if I send it in an e-mail with
$message = $body2;
mail($to, $subject, $message, $headers);
everything is fine.
But when I try to add something to the message, I fails.
$message = $body2 . “extra text”;
Any idea?
cynjut
(Dave Burgess)
December 1, 2016, 9:05pm
2
Try this:
$message = "$body2 extra text";
StephanK
(Stephan Koenig)
December 1, 2016, 10:01pm
3
Great! Works. Thank you so much!
StephanK
(Stephan Koenig)
December 1, 2016, 10:22pm
4
One more question:
How do I check if $body2 is empty?
if (empty("$body2")) {
(some command)
} else {
(other command)
}
I have tried various versions, but I could not get it running
If I get an MMS (picture message) the the body of the text seems to be empty. I don’t know any other way to check if it is a MMS.
cynjut
(Dave Burgess)
December 1, 2016, 10:32pm
5
I think length{} (or is it strlen() - I get PERL and PHP mixed up at this level) will serve your purpose. It seems to me that it returns the length of the variable turned into a string. Zero (0) means the string is empty.
StephanK
(Stephan Koenig)
December 1, 2016, 11:03pm
6
Thank you.
if (strlen("$body2") == 0)
works.
All done!
StephanK
(Stephan Koenig)
December 1, 2016, 11:20pm
7
No. negative.
Length always returns zero, so always TRUE.
$body2 is not always empty.
StephanK
(Stephan Koenig)
December 2, 2016, 2:40am
9
Thank you. You guys are amazing!
Now I have my text message to email notifications running!
1 Like