Can I send a text message from XOJO - Linux program?

So I am working on an inventory program ( personal use ) that when certain elements reach a specified value I would like a text message with the value and item nomenclature sent to my phone and my girlfriends phone. Is there a way to do this? I know email is possible, but I want a text message instead.

As I noted in the title, I am using Linux as my platform ( MS sucks ( been 100% Linux since 1999 ) and Mac is out of my pocketbook range )

I did such a thing using Raspberry Pi and add-on GSM module since I did not wanted to use any SMS-gateway services.

1 Like

If you’re open to using an online service for this, I have done it multiple times with different providers.

Options include Amazon SNS and Twilio. Neither require plugins and can be done entirely in Xojo code with URLConnection.

3 Likes

If you want “some” kind of instant text message and not only SMS, you could try telegram, you can use it’s API to send messages with only a call to an URL, even with curl from shell if you want.

1 Like

care to expand the explanation ?

Disclaimer: I don’t use the below. For messaging I use a google account and send emails direct.

I think there is a low cost associated with almost all services that send actual SMS (like Twillio) - I think cost is around $0.004 - $0.04 per SMS (depending on locale/service).

Alternatively you could use a chat service to message. This might be of help:

As for Telegram, you look it up here: https://telegram.org
It’s API is documented here (seems free of charge): Telegram APIs

Ten days ago I gave a solution here: Xojo is able to send texts directly via BulkSMS.com

1 Like

When inventory hits a preset value, my girlfriend and I are notified of the item(s) via text. Which works when one of us is in town. Then whichever one of us is in town can then purchase the item(s) before we head home. We live off-grid and going to town is time consuming, so the idea is to set this up so we can get stuff while we are out.

1 Like

You can email a text message to your phone


AT&T:* <phonenumber>@txt.att.net
Verizon:* <phonenumber>@vtext.com
T-Mobile:* <phonenumber>@tmomail.net

2 Likes

Okay, I have been reading, attempting, reading some more and attempting some more and I have not been successful in making this work.

From what I understand I need to have a ServerSocket on the window in question. So I put one there


Then I added this code:

' set up the socket--Socket1 is an SMTPSocket
Socket1.Address = "smtp.gmail.com"
Socket1.Port = 25
If AuthenticateBox.Text = True Then
  Socket1.UserName = "***"
  Socket1.Password = "*****"
Else
  Socket1.UserName = ""
End If

Var mail As New EmailMessage

mail.FromAddress = "****@gmail.com"
mail.Subject = "Test"
mail.BodyPlainText = "If this works..."
'mail.BodyHTML = HtmlField.Text
mail.Headers.AddHeader("X-Mailer","Example SMTP Demo")

' add recipients
Var CR As String = EndOfLine.CR
Var LF As String = EndOfLine.LF
Var s As String

s = "9999999999@vtext.com".ReplaceAll(",", CR)
s = s.ReplaceAll(EndOfLine.CRLF, CR)

Var recipients() As String
recipients = s.ToArray(CR)

For Each recipient As String In recipients
  mail.AddRecipient(recipient.Trim)
Next

'' add cc recipients
's = CCAddress.Text.ReplaceAll(",", CR)
's = s.ReplaceAll(EndOfLine.CRLF, CR)
'recipients.RemoveAllRows
'recipients = s.ToArray(CR)
'
'For Each recipient As String In recipients
'mail.AddCCRecipient(recipient.Trim)
'Next

'Var file As EmailAttachment
'
'' add attachments
'If Not fileField.Text.IsEmpty Then
'file = New EmailAttachment
'file.LoadFromFile(New FolderItem(fileField.Text, FolderItem.PathModes.Native))
'mail.Attachments.Add(file)
'End If

' send the email
Socket1.Messages.Add(mail)
Socket1.SendMail

And I get a whole slew of errors. The code is from the help pages. I have tried a few different ways to change it but
 I have never done this before so I am kind of flying blind. Anyhow in a button I have this code

If Me.Caption = "Connect" Then
  ServerSocket1.Address = "smtp.gmail.com"
  ServerSocket1.Port = 110
  
  ServerSocket1.UserName = "***"
  ServerSocket1.Password = "***"
  
  ServerSocket1.Connect
  Me.Caption = "Disconnect"
Else
  ServerSocket1.DisconnectFromServer
  Me.Caption = "Connect"
End If

And a whole litany of errors there
 what am I missing or doing wrong? This is the source of the code listed here → EmailMessage — Xojo documentation

Once I understand what I am doing wrong
 look out! :rofl:

I’m pretty sure Google isn’t going to allow traffic this way. They did have a scheme for ‘app-specific passwords’ that may be of interest.

It’s not a good idea to use Gmail to learn how to send emails. Bill is correct about the app specific passwords.

You said that that you get some errors. But which errors do you get where?

After reading all messages it seems we have gone from needing to send text messages to sending emails that will be converted to text messages.

May I suggest a third solution:

Only Two lines of code are needed to send a message through Pushover:

Var conn as new URLConnection 
conn.Send("POST", "https://url_to_pushover_api")

Pushover notifications can use custom sounds for high priority, can be silenced for a few minutes or several days and many more features.

2 Likes

there’s also apps to monitor and send notifications like

I am trying to find the documentation for sending text messages. All I seem to find is email. So I figure might as well learn that too. But I still haven’t figured out how to send a text message. Since Linux has native SMS capabilities I am hoping to use that.

Brandon WarlickPro

9d

You can email a text message to your phone


AT&T:* <phonenumber>@txt.att.net
Verizon:* <phonenumber>@vtext.com
T-Mobile:* <phonenumber>@tmomail.net

This is why I thought I needed the email side of things


Since we may need to do this in one of our programs, we have been looking at different options. I just wanted to alert Xojo devs that AT&T will be shutting down their gateway on June 17th. Per google:

" AT&T is discontinuing its email-to-text and text-to-email service on June 17, 2025. This means that users will no longer be able to send or receive text messages via email using the AT&T network. The email addresses used for this service, such as those ending in @txt.att.net or @mms.att.net, will no longer be functional."

ServerSocket is the wrong control. It is for receiving, not sending. Use UrlConnection or shell into the linux commands.

1 Like

If you’re wanting to send email rather than SMS that is very doable and works fine with Google.
My use case was to provide a ‘noreply’ email with a 1-time password for users to reset theirs, but would work for notifications.
I did this for a web app using Sending email from your app — Xojo documentation

I created a dedicated gmail account for the purpose - IIRC you need to set up 2FA and create app-specific password for this to enable SMTP, which was the main obstacle (google has helpful instructions on how to enable this).