# Abp.Sms.TencentCloud
(opens new window) (opens new window) (opens new window) (opens new window) (opens new window)
Abp TencentCloud SMS module.
# Installation
Install the following NuGet packages. (see how (opens new window))
- EasyAbp.Abp.Sms.TencentCloud
Add
DependsOn(typeof(AbpSmsTencentCloudModule))
attribute to configure the module dependencies. (see how (opens new window))
# Usage
Configure by AbpTencentCloudCommonOptions and AbpTencentCloudSmsOptions.
public override void ConfigureServices(ServiceConfigurationContext context) { Configure<AbpTencentCloudCommonOptions>(op => { op.SecretId = "pUqsqkj1EhAYJXbSjRupWDviPAMyEaSrH5vY"; op.SecretKey = "20DDOExLNQCTRcsogtP9AEQHI1Tcnu5R"; }); Configure<AbpTencentCloudSmsOptions>(op => { op.DefaultSmsSdkAppid = "1400000000"; op.DefaultSign = "多态科技"; }); }
You can also use ABP settings (opens new window) to control the values of the above options. We recommend to you a great tool module to manage settings: Abp.SettingUI (opens new window).
Try to send a SMS message.
var code = "123456"; // The generated verification code var templateId = "400000"; // TencentCloud SMS template ID var phoneNumber = "+8613000000000"; var smsSender = ServiceProvider.GetRequiredService<ISmsSender>(); // The "text" param has no effect in TencentCloud SMS, but it cannot be null or empty. const string text = "placeholder"; var smsMessage = new SmsMessage(phoneNumber, text); smsMessage.Properties.Add(AbpSmsTencentCloudConsts.TemplateIdPropertyName, templateId); smsMessage.Properties.Add(AbpSmsTencentCloudConsts.TemplateParamSetPropertyName, new [] {code}); await smsSender.SendAsync(smsMessage);