<%@ page contentType="text/html; charset=euc-kr" import="java.util.*, javax.mail.*, javax.mail.internet.*" %>
<%Properties msgProperties = new Properties();msgProperties.put("mail.smtp.host", "localhost");Session msgSession = Session.getDefaultInstance(msgProperties, null);try {MimeMessage msg = new MimeMessage(msgSession);String mailfrom_name = request.getParameter("from_name");String mailfrom = mailfrom_name + "<" + request.getParameter("from_mail") + ">";InternetAddress from = new InternetAddress(mailfrom);msg.setFrom(from);String mailto_name = request.getParameter("to_name");String mailto = mailto_name + "<" + request.getParameter("to_mail") + ">";InternetAddress to = new InternetAddress(mailto);msg.setRecipient(Message.RecipientType.TO, to);String title = request.getParameter("title");msg.setSubject(title,"8859_1");String content = request.getParameter("content");msg.setContent(content, "text/html; charset=8859_1");msg.setHeader("Content-type", "text/html; charset=EUC-KR");Transport.send(msg);%><script>alert('메일이 정상적으로 발송되었습니다.');history.back();</script><%}catch (MessagingException e) {out.println(e.getMessage());%><script>alert('메일 발송이 실패하였습니다!');history.back();</script><% } %>