注册阿里云
https://www.aliyun.com
开通短信服务
第一步:在产品中找到 云通信 → 短信服务。
第二步:点击免费开通。
第三步:创建签名。
第四步:添加模板。
栗子
在 maven 中引入包:
<dependency>
<groupId>com.github.qcloudsms</groupId>
<artifactId>qcloudsms</artifactId>
<version>1.0.6</version>
</dependency>
发送短信:
- 查看用户信息,可以找到 accessKeyId、accessKeySecret。
- templateCode:模板ID。
- signName:签名内容。
public Integer sendMessage(String phone, String code) {
try {
System.