# Abp.Sms.TencentCloud

ABP version (opens new window) NuGet (opens new window) NuGet Download (opens new window) GitHub stars (opens new window)

Abp TencentCloud SMS module.

# Installation

  1. Install the following NuGet packages. (see how (opens new window))

    • EasyAbp.Abp.Sms.TencentCloud
  2. Add DependsOn(typeof(AbpSmsTencentCloudModule)) attribute to configure the module dependencies. (see how (opens new window))

# Usage

  1. 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).

  2. 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);
Last Updated: 12/28/2020, 9:17:33 AM