mobile
Send SMS API with Real Phone Numbers and Consent Controls
Send SMS from a MailSlurp phone number, test replies and OTP journeys, and keep outbound messaging safe with recipient consent and received-message evidence.
The MailSlurp send SMS API lets you send a text message from a provisioned phone number. Use it for approved, consent-based replies and transactional workflows, or to create a controlled two-way conversation in a test environment.
MailSlurp also gives you the receive side of the workflow. After sending a message, you can wait for a reply, forward it to a webhook, inspect it in the dashboard, and assert what your application did with it.
Quick answer
- Provision a MailSlurp phone number.
- Confirm that the destination has consented to receive messages.
- Send from the phone number using the SMS API.
- Record the send result with the test or application workflow.
- Receive replies with the receive SMS API or an SMS webhook.
- Assert the final customer-visible or application outcome.
By default, MailSlurp permits outbound SMS to numbers that have initiated contact with your phone number. Contact support when an approved use case needs a different sending policy.
Send a text message
Use a phone number you have already provisioned in MailSlurp. Keep the MailSlurp phone number ID for API operations and the displayed number for the customer or test device.
await mailslurp.phoneController.sendSmsFromPhoneNumber({
phoneNumberId: sendingNumber,
sendPhoneNumberOptions: {
to: '+14155551212',
message: 'Hello from Mailslurp'
}
});
A successful send call proves that the request was accepted. For a useful end-to-end test, continue until the expected message or reply has been received and the product reaches the correct state.
When to use outbound SMS
Reply to an inbound message
Start with a number that contacted your MailSlurp number, then send the reply from the same phone-number workflow. This is a practical way to test support, appointment, order, or confirmation conversations.
Exercise a two-way application flow
Send a controlled message, reply from the destination, and use a webhook to route the inbound text into your application. Assert that the reply is attached to the correct user or conversation.
Test SMS alongside email
For signup, recovery, or notifications that use both channels, pair the phone number with a MailSlurp inbox. Verify that the SMS and email reach the same test user and that fallback rules do not leave two active verification paths.
Consent and safe test design
Only send to numbers whose owners have agreed to receive the message. Keep production recipients out of development and CI data, and use controlled test destinations wherever possible.
Before enabling a workflow, confirm:
- how consent is captured and withdrawn,
- which message types the recipient expects,
- what your application does when a send fails,
- how a reply is associated with the correct customer,
- whether the destination and sender format work in the intended region.
The default initiated-contact restriction is useful during two-way development because it keeps the send path tied to a number that has already messaged you.
Test a send-and-reply workflow
- Assign the MailSlurp number to a test conversation.
- Send an inbound SMS to establish the controlled contact.
- Use the send SMS API to reply.
- Check the reply on the destination device or test number.
- Send another reply back to the MailSlurp number.
- Wait for the message or receive it through a webhook.
- Assert that your application records one reply in the correct conversation.
This sequence catches errors that a send-only mock misses: wrong number ownership, broken reply routing, stale conversation state, and duplicated webhook processing.
Common problems
The destination is not permitted
Confirm that the number has initiated contact with your MailSlurp phone number. If your approved workflow needs broader outbound access, contact MailSlurp support before building around it.
The send succeeds but the product state is wrong
Continue the test through the reply or expected customer action. Store the MailSlurp phone number ID and message IDs with the test output so you can compare the SMS history with the application record.
Replies are attached to the wrong user
Do not identify a conversation from message text alone. Preserve the sender, recipient, MailSlurp phone number ID, and message identity when routing the reply.
A retry creates duplicate customer messages
Make your own send orchestration aware of the logical notification or conversation action. Before retrying after an ambiguous failure, check the recorded send result and the message history available to the workflow.
FAQ
Can MailSlurp send SMS?
Yes. Send from a provisioned MailSlurp phone number for consent-based workflows. By default, the destination must have initiated contact with your number.
Can I receive a reply after sending?
Yes. Read replies through the SMS API, wait for the expected message in a test, or forward inbound SMS to your server with a phone-number webhook.
Is the send SMS API suitable for OTP testing?
MailSlurp is especially useful for receiving and testing OTP messages sent by the system under test. For a broader two-way or cross-channel auth journey, you can combine outbound SMS, inbound waits, phone numbers, and MailSlurp inboxes.
Where can I see the messages?
Open the phone number in the MailSlurp dashboard for a human-readable thread, or use the SMS API for automated retrieval and assertions.