
Security News
minimatch Patches 3 High-Severity ReDoS Vulnerabilities
minimatch patched three high-severity ReDoS vulnerabilities that can stall the Node.js event loop, and Socket has released free certified patches.
psblab.gitlab.yandexcloud.net/oss/go-sms-sender.git
Advanced tools
This is a powerful open-source library for sending SMS message, which will help you to easily integrate with the popular SMS providers. And it has been applied to Casdoor, if you still don’t know how to use it after reading README.md, you can refer to it.
We support the following SMS providers, welcome to contribute.
Use go get to install:
go get github.com/casdoor/go-sms-sender
Different SMS providers need to provide different configuration, but we support a unit API as below to init and get the SMS client.
func NewSmsClient(provider string, accessId string, accessKey string, sign string, template string, other ...string) (SmsClient, error)
provider the name of SMS provider, such as Aliyun SMSaccessIdaccessKeysign the sign nametemplate the template codeother other configurationAfter initializing the SMS client, we can use the following API to send message.
SendMessage(param map[string]string, targetPhoneNumber ...string) error
param the parameters in the SMS template, such as 6 random numberstargetPhoneNumber the receivers, such as +8612345678910Please get necessary information from Twilio console
package main
import "github.com/casdoor/go-sms-sender"
func main() {
client, err := go_sms_sender.NewSmsClient(go_sms_sender.Twilio, "ACCOUNT_SID", "AUTH_TOKEN", "", "TEMPLATE_CODE")
if err != nil {
panic(err)
}
params := map[string]string{}
params["code"] = "123456"
phoneNumer := "+8612345678910"
err = client.SendMessage(params, phoneNumer)
if err != nil {
panic(err)
}
}
Before you begin, you need to sign up for an Aliyun account and retrieve your Credentials.
package main
import "github.com/casdoor/go-sms-sender"
func main() {
client, err := go_sms_sender.NewSmsClient(go_sms_sender.Aliyun, "ACCESS_KEY_ID", "ACCESS_KEY_SECRET", "SIGN_NAME", "TEMPLATE_CODE")
if err != nil {
panic(err)
}
params := map[string]string{}
params["code"] = "473956"
phoneNumer := "+8612345678910"
err = client.SendMessage(params, phoneNumer)
if err != nil {
panic(err)
}
}
package main
import "github.com/casdoor/go-sms-sender"
func main() {
client, err := go_sms_sender.NewSmsClient(go_sms_sender.TencentCloud, "secretId", "secretKey", "SIGN_NAME", "TEMPLATE_CODE", "APP_ID")
if err != nil {
panic(err)
}
params := map[string]string{}
params["0"] = "473956"
phoneNumer := "+8612345678910"
err = client.SendMessage(params, phoneNumer)
if err != nil {
panic(err)
}
}
package main
import "github.com/casdoor/go-sms-sender"
func main() {
client, err := go_sms_sender.NewSmsClient(go_sms_sender.Netgsm, "yourAccessId", "yourAccessKey", "yourSign", "yourTemplate")
if err != nil {
panic(err)
}
params := map[string]string{}
params["param1"] = "value1"
params["param2"] = "value2"
phoneNumer := "+8612345678910"
err = client.SendMessage(params, phoneNumer)
if err != nil {
panic(err)
}
}
To run tests for the go-sms-sender library, navigate to the root folder of the project in your terminal and execute the following command:
go test -v ./...
you can modify mock_test.go file to mock an other tests
This project is licensed under the Apache 2.0 license.
FAQs
Unknown package
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
minimatch patched three high-severity ReDoS vulnerabilities that can stall the Node.js event loop, and Socket has released free certified patches.

Research
/Security News
Socket uncovered 26 malicious npm packages tied to North Korea's Contagious Interview campaign, retrieving a live 9-module infostealer and RAT from the adversary's C2.

Research
An impersonated golang.org/x/crypto clone exfiltrates passwords, executes a remote shell stager, and delivers a Rekoobe backdoor on Linux.