
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
A simple SMS framework for sending messages via Twilio.
In your Gemfile add:
gem "minitext"
Install your gems:
bundle install
First set up a gateway:
Minitext.configure do |config|
config.gateway = Minitext::TwilioGateway.new(account_sid: 'your_twilio_account_sid', auth_token: 'your_twilio_auth_token')
end
Then send some texts:
Minitext.text(from: '1234567890', to: '9876543210', body: 'Hello world').deliver
You can send using a Twilio Messaging Service instead of a from number by specifying it's SID:
Minitext.text(messaging_service_sid: 'your-messaging-service-sid', to: '9876543210', body: 'Hello world').deliver
You can send mms texts with a media_url:
Minitext.text(from: '1234567890', to: '9876543210', body: 'Hello world', media_url: 'http://placekitten.com/200/300').deliver
If you want to restrict the numbers that you can send texts to, use the AllowlistProxy
wrapper.
Set up your allowlist proxy:
Minitext.configure do |config|
allowlist = ['9876543210']
twilio_gateway = Minitext::TwilioGateway.new(account_sid: 'your_twilio_account_sid', auth_token: 'your_twilio_auth_token')
config.gateway = Minitext::AllowlistProxy.new(allowed: allowlist, gateway: twilio_gateway)
end
Then send some texts:
Minitext.text(from: '1234567890', to: '9876543210', body: 'This text should succeed.').deliver
Minitext.text(from: '1234567890', to: '5559991111', body: 'This text should fail.').deliver
Here are some examples of how you might configure Minitext in different Rails environments.
Minitext.configure do |config|
config.gateway = Minitext::TwilioGateway.new(account_sid: '123', auth_token: 'abc')
# You can set a default `from` number for all messages if you don't want to specify it everywhere you call Minitext.text
# config.message_defaults = { from: '5551234567' }
# Or, you can specify a messaging_service_sid instead:
# config.message_defaults = { messaging_service_sid: 'your_default_messaging_service_sid' }
end
Minitext.configure do |config|
config.gateway = Minitext::TestGateway.new
end
Minitext.configure do |config|
# You could allow devs to send messages to themselves in development mode if they start the server with an
# environment variable, like so: `SEND_LIVE_SMS_TO=5551234567 rails s`
allowlist = Array(ENV.fetch("SEND_LIVE_SMS_TO", nil)).compact
twilio_gateway = Minitext::TwilioGateway.new(account_sid: '123', auth_token: 'abc')
config.gateway = Minitext::AllowlistProxy.new(allowed: allowlist, gateway: twilio_gateway)
end
If you do not specify a gateway via configuration, Minitext uses a TestGateway
object by default.
Example test:
Minitext.text(from: '1234567890', to: '9876543210', body: 'This text should succeed.').deliver
assert_equal 1, Minitext.gateway.deliveries.length
Don't forget to cleanup after yourself in your teardown methods:
Minitext.gateway.deliveries.clear
FAQs
Unknown package
We found that minitext demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.