Curiosus.SMS.Iqsms
ISmsSender implementation for IQSMS. Use it to send SMS via an iqsms.ru account,
directly or through Curiosus.Notifications.SMS.
Installation
dotnet add package Curiosus.SMS.Iqsms
Usage
IqsmsOptions requires Login and Password; Sender (sender name) is optional.
For example, bound from configuration:
IqsmsOptions:
Login: my-login
Password: my-password
Sender: MyCompany
AutoTransformPhoneNumber: true
var iqsmsOptions = configuration.GetSection("IqsmsOptions").Get<IqsmsOptions>()!;
// registers IIqsmsSender and, by default, ISmsSender
services.AddIqsmsSender(iqsmsOptions);
var result = await smsSender.SendSmsAsync("89123456789", "Hello iqsms!", cancellationToken);
if (!result.IsSuccess)
{
logger.LogError("Failed to send SMS: {Response}", result.Body.ResponseJson);
}
// per-message credentials or sender name
await smsSender.SendSmsAsync("+79123456789", "Hello!", new IqsmsExtraParams(null, null, "OtherSender"));
Pass useAsDefaultSender: false to register only IIqsmsSender (e.g. when another provider is the default ISmsSender).
Notes:
- iqsms.ru expects numbers as
+71234567890. WithAutoTransformPhoneNumber(defaulttrue) numbers starting with8or7are converted to this format. - Errors are mapped to
SmsError(Auth,Communication,NoMoney,DeliveryError,Unknown); the raw iqsms.ru response is available inSmsSentResult.ResponseJson. Cost and message count are not reported.
A runnable console sample is in samples/Curiosus.SMS.Iqsms.Sample.
HTTP requests go through the HttpClient named IqsmsSender.HttpClientName from IHttpClientFactory,
which AddIqsmsSender registers. Configure it for timeouts, a proxy or resilience handlers:
services.AddHttpClient(IqsmsSender.HttpClientName, client => client.Timeout = TimeSpan.FromSeconds(30));
See also
- Curiosus.SMS —
ISmsSenderabstraction - Curiosus.SMS.Smsc — sender for smsc.ru
- Curiosus.Notifications.SMS — SMS notification channel
- Curiosus.Utils — all packages