@Test public void send() throws Exception { Map<String, Object> email = new HashMap<>(8); email.put("title","测试title"); email.put("content","这是一个测试邮件"); email.put("to","xxxxxxxxxxxxx"); JSONObject jsonObject = new JSONObject(email); }
public ResObject send(@RequestBody Map<String,String> map) { try { SimpleMailMessage email = new SimpleMailMessage(); email.setFrom(from); email.setSubject(map.get("title")); email.setText(map.get("content")); email.setTo(map.get("to")); javaMailSender.send(email); logger.info("\ntime:"+ CommonUtils.getNowDate() +"\nFrom:"+from +"\nTo:"+map.get("to") +"\ntitle:"+email.getSubject() +"\ncontent:"+email.getText()); } catch (Exception e) { return new ResObject(-1,e.getMessage()); } return new ResObject(); }
EmailController { public ResObject send(@RequestBody Map<String,String> map) { try { SimpleMailMessage email = new SimpleMailMessage(); email.setFrom(from); email.setSubject(map.get("title")); email.setText(map.get("content")); email.setTo(map.get("to")); javaMailSender.send(email); logger.info("\ntime:"+ CommonUtils.getNowDate() +"\nFrom:"+from +"\nTo:"+map.get("to") +"\ntitle:"+email.getSubject() +"\ncontent:"+email.getText()); } catch (Exception e) { return new ResObject(-1,e.getMessage()); } return new ResObject(); } }
EmailController { public ResObject send(@RequestBody Map<String,String> map) { try { SimpleMailMessage email = new SimpleMailMessage(); email.setFrom(from); email.setSubject(map.get("title")); email.setText(map.get("content")); email.setTo(map.get("to")); javaMailSender.send(email); logger.info("\ntime:"+ CommonUtils.getNowDate() +"\nFrom:"+from +"\nTo:"+map.get("to") +"\ntitle:"+email.getSubject() +"\ncontent:"+email.getText()); } catch (Exception e) { return new ResObject(-1,e.getMessage()); } return new ResObject(); }  }
EmailController { public ResObject send(@RequestBody Map<String,String> map) { try { SimpleMailMessage email = new SimpleMailMessage(); email.setFrom(from); email.setSubject(map.get("title")); email.setText(map.get("content")); email.setTo(map.get("to")); javaMailSender.send(email); logger.info("\ntime:"+ CommonUtils.getNowDate() +"\nFrom:"+from +"\nTo:"+map.get("to") +"\ntitle:"+email.getSubject() +"\ncontent:"+email.getText()); } catch (Exception e) { return new ResObject(-1,e.getMessage()); } return new ResObject(); }  ResObject send(@RequestBody Map<String,String> map); ResObject sendAll(@RequestBody Map<String,String> map); }
EmailController { public ResObject send(@RequestBody Map<String,String> map) { try { SimpleMailMessage email = new SimpleMailMessage(); email.setFrom(from); email.setSubject(map.get("title")); email.setText(map.get("content")); email.setTo(map.get("to")); javaMailSender.send(email); logger.info("\ntime:"+ CommonUtils.getNowDate() +"\nFrom:"+from +"\nTo:"+map.get("to") +"\ntitle:"+email.getSubject() +"\ncontent:"+email.getText()); } catch (Exception e) { return new ResObject(-1,e.getMessage()); } return new ResObject(); }  ResObject send(@RequestBody Map<String,String> map); ResObject sendAll(@RequestBody Map<String,String> map);  }