| | |
| | | package com.yeshi.buwan.controller; |
| | | |
| | | import java.io.PrintWriter; |
| | | |
| | | import net.sf.json.JSONObject; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.yeshi.utils.exception.MailSendException; |
| | | import org.yeshi.utils.mail.EmailApiUtil; |
| | | import org.yeshi.utils.mail.EmailInfo; |
| | | |
| | | import com.yeshi.buwan.util.email.MailSenderUtil; |
| | | |
| | | import net.sf.json.JSONObject; |
| | | import java.io.PrintWriter; |
| | | |
| | | @Controller |
| | | @RequestMapping("email") |
| | | public class EmailController { |
| | | |
| | | /** |
| | | * 邮件发送 |
| | | * |
| | | * @param fromAccount |
| | | * 源账户名 |
| | | * @param fromPwd |
| | | * 源密码 |
| | | * @param toAccount |
| | | * 目标账号 |
| | | * @param title |
| | | * 标题 |
| | | * @param content |
| | | * 内容 |
| | | * @param res |
| | | * @param request |
| | | */ |
| | | @RequestMapping(value = "sendEmail") |
| | | public void acFunVideo(String fromAccount, String fromPwd, String toAccount, String title, String content, |
| | | PrintWriter out) { |
| | | boolean isS = MailSenderUtil.sendEmail(toAccount, fromAccount, fromPwd, title, content); |
| | | JSONObject data = new JSONObject(); |
| | | if (isS) { |
| | | data.put("code", 0); |
| | | } else { |
| | | data.put("code", 1); |
| | | data.put("msg", "邮件发送失败"); |
| | | } |
| | | out.print(data.toString()); |
| | | } |
| | | /** |
| | | * 邮件发送 |
| | | * |
| | | * @param fromAccount 源账户名 |
| | | * @param fromPwd 源密码 |
| | | * @param toAccount 目标账号 |
| | | * @param title 标题 |
| | | * @param content 内容 |
| | | */ |
| | | @RequestMapping(value = "sendEmail") |
| | | public void acFunVideo(String fromAccount, String fromPwd, String toAccount, String title, String content, |
| | | PrintWriter out) { |
| | | EmailInfo emailInfo = new EmailInfo(); |
| | | emailInfo.setToEmail(toAccount); |
| | | emailInfo.setTitle(title); |
| | | emailInfo.setFromEmail(fromAccount); |
| | | emailInfo.setFormEmailPwd(fromPwd); |
| | | emailInfo.setContent(content); |
| | | emailInfo.setApp("影视"); |
| | | |
| | | boolean isS = false; |
| | | try { |
| | | EmailApiUtil.sendEmail(emailInfo); |
| | | isS = true; |
| | | } catch (MailSendException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | JSONObject data = new JSONObject(); |
| | | if (isS) { |
| | | data.put("code", 0); |
| | | } else { |
| | | data.put("code", 1); |
| | | data.put("msg", "邮件发送失败"); |
| | | } |
| | | out.print(data.toString()); |
| | | } |
| | | |
| | | } |