PHP Texts Not Being Sent [SOLVED]

Phillip
Posts: 39
Joined: Thu Aug 25, 2022 11:57 pm

PHP Texts Not Being Sent [SOLVED]

Postby Phillip » Mon Sep 01, 2025 7:10 pm

I have used a POST method of sending PHP texts for several years and for some reason I can no longer do so. Here is an example of the POST code that I have used:

Code: Select all

 void loop() {
       postData = postVariable + "99";
      {
        if (client.connect(server, portNumber))  
            {
              client.println("POST /includes/simple_text.php HTTP/1.1");
              client.println( "Host: www.myWebSite.com" ); 
              client.println( "Content-Type: application/x-www-form-urlencoded" );
              client.print("Content-Length: ");
              client.println(postData.length()); 
              client.println();
              client.print(postData);

              Serial.println(postData);   
              Serial.println("TEXT Sent");
            }
            if (client.connected()) {
                client.stop();
             }
             delay(60000);
      }
      Serial.println(postData);      
      delay(10000);
  }
If I simply refresh the PHP script file in the includes folder the text will be sent and received. From this I am certain that all of the PHP script is correct as well as the T-Mobile SMS Gateway Domain which is 'cell#@tmomail.net'. Neither the code nor the PHP script has been modified in any way to prevent the texts from being sent. This used to work perfectly.

Previously I was using CenturyLink for internet service and Verizon as my cell service provider. I am now using StarLink for internet and T-Mobile for cell service. I keep suspecting that StarLink is the problem but I cannot prove that. Since installing StarLink I have received emails/texts but this may not be related to my Arduino text problem.

My PHP script makes use of the PHP mail() function which I have read is usually blocked by hosting services due to it being abused by spammer's. I have checked with my hosting service and was told that that PHP function has not been blocked in any way.

If anyone has any idea what may be causing this I'm all ears.

Thank you,
Last edited by Phillip on Wed Sep 03, 2025 3:39 pm, edited 1 time in total.

MicroController
Posts: 2663
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: PHP Texts Not Being Sent

Postby MicroController » Mon Sep 01, 2025 8:20 pm

Check if you get any error when connecting, if not, check what HTTP result code you receive. If any error, check what error you're getting.
Also, closing the connection w/o reading anything from the HTTP response may also cause problems.

Phillip
Posts: 39
Joined: Thu Aug 25, 2022 11:57 pm

Re: PHP Texts Not Being Sent

Postby Phillip » Mon Sep 01, 2025 9:09 pm

Thanks for your comments and suggestions. If you mean PHP error checking I have done that repeatedly. As noted earlier, I can send/receive the text by just refreshing the PHP file in the includes folder, but not from the Arduino app.

You are correct about not closing the wifi connection. I will do that now. Any thoughts on StarLink causing this?

Thank you.

Phillip
Posts: 39
Joined: Thu Aug 25, 2022 11:57 pm

Re: PHP Texts Not Being Sent

Postby Phillip » Mon Sep 01, 2025 9:16 pm

Just re-checked: I think I did close out the connection as follows:

Code: Select all

if (client.connected()) {
                client.stop();
             }
Thanks!

Phillip
Posts: 39
Joined: Thu Aug 25, 2022 11:57 pm

Re: PHP Texts Not Being Sent

Postby Phillip » Tue Sep 02, 2025 2:47 am

Just ran an http request app and did connect with the website I have been trying to ping. This http request returned all of the index.php's html markup.

Will know more tomorrow. Thanks!

MicroController
Posts: 2663
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: PHP Texts Not Being Sent

Postby MicroController » Tue Sep 02, 2025 8:08 am

If you mean PHP error checking I have done that repeatedly.
I actually mean checking on the ESP, i.e. if (client.connect(server, portNumber)) actually returns true.

Closing the HTTP connection right after sending a request without waiting for the server to respond may reset the connection and cause the server to kill the running PHP script before it is done. How much the PHP accomplishes before being stopped by the server may depend on network timing, server configuration, &c.

Phillip
Posts: 39
Joined: Thu Aug 25, 2022 11:57 pm

Re: PHP Texts Not Being Sent

Postby Phillip » Tue Sep 02, 2025 3:19 pm

@MicroController

Thanks for your feedback. I will tweak my code as you suggested.

I am still puzzled as to why my code sent PHP texts (as coded) perfectly for years and then just stops. Again, I am pointing my finger at StarLink but, thus far, I cannot prove that. This is the craziest Arduino/EXP32 problem I have ever faced.

Thank for your help.

Phillip
Posts: 39
Joined: Thu Aug 25, 2022 11:57 pm

Re: PHP Texts Not Being Sent

Postby Phillip » Wed Sep 03, 2025 3:39 pm

I have finally begun to receive texts.

My original code made use of HTTP requests. I changed my code to use HTTPS requests and that worked. I also incorporated the use of an API key value for further security.

It could be that StarLink requires HTTPS, but I could never determine if that was true or not. Regardless, HTTPS requests worked - after nearly two weeks of trial and error - but I'm finally good to go now.

Lesson learned.

Thanks!

Who is online

Users browsing this forum: Barkrowler, Bytespider, PetalBot and 5 guests