Set OTPMOCK_URL=https://api.otpmock.com in your test environment, point the Mutlucell client at it, and use your otpmock API key as the Mutlucell credential. Your application code doesn't change, and production keeps sending real SMS through Mutlucell.
Setup
Apps usually post the XML directly, so only the host changes. The official PHP package hard-codes its host and can't be redirected; post the XML yourself in tests. Errors come back as bare codes: 23 wrong credentials, 20 bad XML, 22 no credits.
const MUTLUCELL_URL = process.env.OTPMOCK_URL ?? "https://smsgw.mutlucell.com";
const xml = `<?xml version="1.0" encoding="UTF-8"?>
<smspack ka="${process.env.MUTLUCELL_USER}" pwd="${process.env.MUTLUCELL_PASSWORD}" org="MUTLUCELL">
<mesaj><metin>Doğrulama kodunuz: ${code}</metin><nums>5321234567</nums></mesaj>
</smspack>`;
const res = await fetch(`${MUTLUCELL_URL}/smsgw-ws/sndblkex`, {
method: "POST",
headers: { "content-type": "text/xml; charset=UTF-8" },
body: xml,
});
const result = await res.text(); // "$12345678#1.0" or an error codeimport os
import requests
MUTLUCELL_URL = os.environ.get("OTPMOCK_URL", "https://smsgw.mutlucell.com")
xml = f"""<?xml version="1.0" encoding="UTF-8"?>
<smspack ka="{os.environ['MUTLUCELL_USER']}" pwd="{os.environ['MUTLUCELL_PASSWORD']}" org="MUTLUCELL">
<mesaj><metin>Doğrulama kodunuz: {code}</metin><nums>5321234567</nums></mesaj>
</smspack>""" # pwd = otpmock API key in tests
res = requests.post(f"{MUTLUCELL_URL}/smsgw-ws/sndblkex", data=xml.encode("utf-8"),
headers={"Content-Type": "text/xml; charset=UTF-8"})
result = res.text # "$12345678#1.0" or an error codeString base = System.getenv().getOrDefault("OTPMOCK_URL", "https://smsgw.mutlucell.com");
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><smspack ka=\"" + user + "\" pwd=\"" + pwd // pwd = otpmock API key in tests
+ "\" org=\"MUTLUCELL\"><mesaj><metin>" + text + "</metin><nums>05321234567</nums></mesaj></smspack>";
HttpRequest req = HttpRequest.newBuilder(URI.create(base + "/smsgw-ws/sndblkex"))
.header("Content-Type", "text/xml; charset=UTF-8")
.POST(HttpRequest.BodyPublishers.ofString(xml))
.build();
// Response: "$12345678#1.0" or an error code such as "23".using System.Security;
var mutlucellUrl = Environment.GetEnvironmentVariable("OTPMOCK_URL") ?? "https://smsgw.mutlucell.com";
var user = Environment.GetEnvironmentVariable("MUTLUCELL_USER");
var pwd = Environment.GetEnvironmentVariable("MUTLUCELL_PASSWORD"); // otpmock API key in tests
var xml = $"<?xml version=\"1.0\" encoding=\"UTF-8\"?><smspack ka=\"{SecurityElement.Escape(user)}\" pwd=\"{SecurityElement.Escape(pwd)}\" org=\"MUTLUCELL\">"
+ $"<mesaj><metin>Doğrulama kodunuz: {code}</metin><nums>5321234567</nums></mesaj></smspack>";
var res = await new HttpClient().PostAsync(mutlucellUrl + "/smsgw-ws/sndblkex",
new StringContent(xml, Encoding.UTF8, "text/xml"));
var result = await res.Content.ReadAsStringAsync(); // "$12345678#1.0" or an error codeuse GuzzleHttp\Client;
$mutlucellUrl = getenv('OTPMOCK_URL') ?: 'https://smsgw.mutlucell.com';
$user = htmlspecialchars(getenv('MUTLUCELL_USER'));
$pwd = htmlspecialchars(getenv('MUTLUCELL_PASSWORD')); // otpmock API key in tests
$xml = '<?xml version="1.0" encoding="UTF-8"?>'
. "<smspack ka=\"$user\" pwd=\"$pwd\" org=\"MUTLUCELL\">"
. "<mesaj><metin>Doğrulama kodunuz: $code</metin><nums>5321234567</nums></mesaj></smspack>";
$result = (string) (new Client())->post("$mutlucellUrl/smsgw-ws/sndblkex", [
'headers' => ['Content-Type' => 'text/xml; charset=UTF-8'],
'body' => $xml,
])->getBody(); // "$12345678#1.0" or an error coderequire "net/http"
# Apps post the XML directly, so only the host changes.
MUTLUCELL_URL = ENV.fetch("OTPMOCK_URL", "https://smsgw.mutlucell.com")
xml = <<~XML
<?xml version="1.0" encoding="UTF-8"?>
<smspack ka="#{ENV["MUTLUCELL_USER"]}" pwd="#{ENV["MUTLUCELL_PASSWORD"]}" org="MUTLUCELL">
<mesaj><metin>Doğrulama kodunuz: #{code}</metin><nums>5321234567</nums></mesaj>
</smspack>
XML
# pwd = otpmock API key in tests
res = Net::HTTP.post(URI("#{MUTLUCELL_URL}/smsgw-ws/sndblkex"), xml, "Content-Type" => "text/xml; charset=UTF-8")
result = res.body # "$12345678#1.0" or an error code// Mutlucell has no official Go SDK; call its HTTP API with net/http, only the host changes.
base := os.Getenv("OTPMOCK_URL")
if base == "" {
base = "https://smsgw.mutlucell.com"
}
xml := fmt.Sprintf(`<?xml version="1.0" encoding="UTF-8"?>
<smspack ka="%s" pwd="%s" org="MUTLUCELL"><mesaj><metin>%s</metin><nums>5321234567</nums></mesaj></smspack>`,
os.Getenv("MUTLUCELL_USER"), os.Getenv("MUTLUCELL_PASSWORD"), msg) // pwd = otpmock API key in tests
res, err := http.Post(base+"/smsgw-ws/sndblkex", "text/xml; charset=UTF-8", strings.NewReader(xml)) // "$12345678#1.0" or an error codeEach language is tested in CI against otpmock with the provider's official SDK, or its plain HTTP API where no SDK can be pointed at another host.
Credentials. In the test environment, use your otpmock API key as pwd (Mutlucell accepts an API key in that attribute too).
What otpmock emulates
| Endpoint | What it does |
|---|---|
POST /smsgw-ws/sndblkex | XML <smspack ka pwd org><mesaj><metin/><nums/></mesaj></smspack>; response $<packetID>#<credits> or an error code |
Responses and errors follow Mutlucell's own format, so the SDK parses them as usual. Authentication failures and an exhausted monthly allowance also come back in Mutlucell's error shape.
Try it with cURL
Before wiring your app, check the emulation by hand. Put your own key in OTPMOCK_API_KEY; the number is made up. Keep the message text ASCII when you run this from a Windows terminal, which can garble accented letters on the command line.
curl https://api.otpmock.com/smsgw-ws/sndblkex \
-H "content-type: text/xml; charset=UTF-8" \
-d '<?xml version="1.0" encoding="UTF-8"?><smspack ka="x" pwd="'"$OTPMOCK_API_KEY"'" org="MUTLUCELL"><mesaj><metin>Dogrulama kodunuz: 884422</metin><nums>5321230002</nums></mesaj></smspack>'$65625528#1.0The response has Mutlucell's own shape. Now read the code your test would read:
curl https://api.otpmock.com/v1/inbox/%2B905321230002/code \
-H "Authorization: Bearer $OTPMOCK_API_KEY"
{"code":"884422","messageSid":"SM…","receivedAt":1795257752284}Phone numbers
Mutlucell accepts any format (05321234567, 905321234567, 532 123 45 67). otpmock stores Turkish numbers as +905321234567.
How to tell your app uses Mutlucell
Look for any of these in your codebase to confirm where the SMS is sent, and therefore where the otpmock option has to be set:
- requests to
smsgw.mutlucell.com/smsgw-ws/sndblkex <smspack ka=... pwd=...>XML
Read the code in your tests
const phone = otp.randomPhone();
const since = Date.now() - 5_000;
await page.getByRole("button", { name: "Send code" }).click(); // your app calls Mutlucell
const { code } = await otp.waitForCode(phone, { since });The otp helper is a single file: get it from the docs. Full walkthroughs: Playwright, Cypress.
FAQ
Does otpmock send real SMS through Mutlucell?
No. In the test environment your app's Mutlucell requests go to otpmock, which stores the message for 10 minutes and never contacts Mutlucell or any carrier. Production keeps using Mutlucell because otpmock is only enabled when OTPMOCK_URL is set.
Is the official HTTP API SDK supported?
Yes. otpmock's Mutlucell endpoints are tested end to end with the official HTTP API package for Node.js. Other languages work too if their Mutlucell client lets you change the API host.
Which Mutlucell APIs does otpmock support?
POST /smsgw-ws/sndblkex (XML <smspack ka pwd org><mesaj><metin/><nums/></mesaj></smspack>; response $<packetID>#<credits> or an error code).
The free plan includes 300 messages a month. Using an AI coding assistant? Point it at otpmock.com/llms-full.txt.
Get a free API key