当前位置:   article > 正文

阿里云 SDK 邮件推送 SingleSendMail 报错 InvalidMailAddress.NotFound 处理办法_com.aliyuncs.exceptions.clientexception: invalidma

com.aliyuncs.exceptions.clientexception: invalidmailaddress.notfound : the s
  1. public void sendVCode(String email, String vCode) {
  2. try {
  3. // 如果是除杭州region外的其它region(如新加坡region), 需要做如下处理, 这个居然是通过工单文过来的!!!
  4. DefaultProfile.addEndpoint("dm.ap-southeast-1.aliyuncs.com", "ap-southeast-1", "Dm", "dm.ap-southeast-1.aliyuncs.com");
  5. } catch (ClientException e) {
  6. e.printStackTrace();
  7. }
  8. DefaultProfile profile = DefaultProfile.getProfile("ap-southeast-1", "*******", "*******");
  9. IAcsClient client = new DefaultAcsClient(profile);
  10. SingleSendMailRequest request = new SingleSendMailRequest();
  11. request.setTextBody("验证码:" + vCode);
  12. request.setSubject("验证码来啦");
  13. request.setToAddress(email);
  14. request.setAddressType(0);
  15. request.setReplyToAddress(false);
  16. request.setAccountName("service@mail.hknaruto.com");
  17. try {
  18. SingleSendMailResponse response = client.getAcsResponse(request);
  19. System.out.println(new Gson().toJson(response));
  20. } catch (ServerException e) {
  21. e.printStackTrace();
  22. } catch (ClientException e) {
  23. System.out.println("ErrCode:" + e.getErrCode());
  24. System.out.println("ErrMsg:" + e.getErrMsg());
  25. System.out.println("RequestId:" + e.getRequestId());
  26. }
  27. }

 

 

注意这段代码:

  1. try {
  2. // 如果是除杭州region外的其它region(如新加坡region), 需要做如下处理, 这个居然是通过工单文过来的!!!
  3. DefaultProfile.addEndpoint("dm.ap-southeast-1.aliyuncs.com", "ap-southeast-1", "Dm", "dm.ap-southeast-1.aliyuncs.com");
  4. } catch (ClientException e) {
  5. e.printStackTrace();
  6. }

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/201273
推荐阅读
相关标签
  

闽ICP备14008679号