80 lines
2.9 KiB
Plaintext
80 lines
2.9 KiB
Plaintext
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
|
pageEncoding="UTF-8"%>
|
|
<%@ page import="java.util.*"%>
|
|
<%@ page import="javax.activation.*"%>
|
|
<%@ page import="javax.mail.*"%>
|
|
<%@ page import="javax.mail.internet.*"%>
|
|
<%!
|
|
public class MyAuthentication extends Authenticator { //아이디 패스워드 인증받기 함수
|
|
PasswordAuthentication pa;
|
|
public MyAuthentication(String mail, String pwd) {
|
|
pa = new PasswordAuthentication(mail, pwd);
|
|
}
|
|
@Override
|
|
protected PasswordAuthentication getPasswordAuthentication() {
|
|
return pa;
|
|
}
|
|
}
|
|
%>
|
|
<%
|
|
request.setCharacterEncoding("UTF-8");
|
|
// SMTP 서버 주소
|
|
//받는 사람의 정보
|
|
String toEmail = request.getParameter("c_email");
|
|
String c_title = request.getParameter("c_title");
|
|
String c_content = request.getParameter("c_content");
|
|
c_content = "<table style='width:100%;' ><tr><td align=left style='height:80px;width:100%;padding-left:40px;background:#C2424B;'><font color='#ffffff'><b>RESoft BMC System</font> </td></tr><tr><td style='padding-left:60px'><br>" + c_content;
|
|
c_content = c_content + "<br><br><br><br></td></tr><tr><td align=left style='height:60px;width:100%;padding-left:40px;background:#6C6A6A;'><font color='#ffffff'><b>RESoft</font> </td></tr></table>";
|
|
|
|
String c_alert = request.getParameter("c_alert");
|
|
String c_alert2 = request.getParameter("c_alert2");
|
|
if (c_alert == null || c_alert.equals("")){
|
|
c_alert = "Send Email ok";
|
|
}
|
|
|
|
if (c_alert2 == null || c_alert2.equals("")){
|
|
c_alert2 = "Wrong Email Addres. ";
|
|
}
|
|
|
|
String fromName = "REsoft BMC SYstem";
|
|
String fromEmail = "admin@resoft.co.kr";
|
|
try {
|
|
Properties props = new Properties();
|
|
props.put("mail.smtp.host", "smtp.cafe24.com");
|
|
props.put("mail.smtp.port", "587");
|
|
props.put("mail.smtp.auth", "true");
|
|
// 메일 인증
|
|
//Authenticator myauth = new MyAuthentication("admin@c-innovacion.org", "koefA01!"); //by jin@2022.03.02
|
|
Authenticator myauth = new MyAuthentication("e-play2@resoft.co.kr", "jakoreaA01!");
|
|
Session sess = Session.getInstance(props, myauth);
|
|
InternetAddress addr = new InternetAddress();
|
|
addr.setPersonal(fromName, "UTF-8");
|
|
addr.setAddress("admin@resoft.co.kr");
|
|
|
|
Message msg = new MimeMessage(sess);
|
|
msg.setFrom(addr);
|
|
msg.setSubject(c_title);
|
|
msg.setContent(c_content, "text/html;charset=utf-8");
|
|
msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(toEmail));
|
|
|
|
Transport.send(msg);
|
|
|
|
if(!c_alert.equals("no")){
|
|
%>
|
|
<script>
|
|
alert("<%=c_alert%>")
|
|
</script>
|
|
<%
|
|
}
|
|
}
|
|
catch (Exception e) {
|
|
%>
|
|
<script>
|
|
alert("<%=c_alert2%>")
|
|
</script>
|
|
<%
|
|
e.printStackTrace();
|
|
return;
|
|
}
|
|
%>
|
|
|