赞
踩
- public void sendVCode(String email, String vCode) {
- try {
- // 如果是除杭州region外的其它region(如新加坡region), 需要做如下处理, 这个居然是通过工单文过来的!!!
- DefaultProfile.addEndpoint("dm.ap-southeast-1.aliyuncs.com", "ap-southeast-1", "Dm", "dm.ap-southeast-1.aliyuncs.com");
- } catch (ClientException e) {
- e.printStackTrace();
- }
-
- DefaultProfile profile = DefaultProfile.getProfile("ap-southeast-1", "*******", "*******");
- IAcsClient client = new DefaultAcsClient(profile);
-
- SingleSendMailRequest request = new SingleSendMailRequest();
- request.setTextBody("验证码:" + vCode);
- request.setSubject("验证码来啦");
- request.setToAddress(email);
- request.setAddressType(0);
- request.setReplyToAddress(false);
- request.setAccountName("service@mail.hknaruto.com");
-
- try {
- SingleSendMailResponse response = client.getAcsResponse(request);
- System.out.println(new Gson().toJson(response));
- } catch (ServerException e) {
- e.printStackTrace();
- } catch (ClientException e) {
- System.out.println("ErrCode:" + e.getErrCode());
- System.out.println("ErrMsg:" + e.getErrMsg());
- System.out.println("RequestId:" + e.getRequestId());
- }
- }
注意这段代码:
- try {
- // 如果是除杭州region外的其它region(如新加坡region), 需要做如下处理, 这个居然是通过工单文过来的!!!
- DefaultProfile.addEndpoint("dm.ap-southeast-1.aliyuncs.com", "ap-southeast-1", "Dm", "dm.ap-southeast-1.aliyuncs.com");
- } catch (ClientException e) {
- e.printStackTrace();
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。