<%@ page language="java" errorPage="error.jsp" contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="http://xmlns.oracle.com/j2ee/jsp/tld/ojsp/email.tld" prefix="mail" %>
<%@ include file="../demoUtil.jsp" %>

<b><font color="red">
Security Note - PLEASE READ!
</font></b>
<br>
This demo is intentionally not set up to run out-of-the-box. To get it running, please do the following:
<ul>
<li>modify the host name in the source file "sendmail.jsp" by replacing the value of "your-smtp-host-please-change".
<li>modify the sendmail.properties file to determine what level of attachment support you want. The valid options are "none", "client", "server". The default is "none", for security reasons. To run this demo, you will need to set it to "server".
</ul>
In both of these cases, they are not settable directly on this page in order to avoid the security risk of email system abuse. You will need to make these modifications outside of this demo and then restart the demo for the changes to take effect.
<br>
Please do not let this web page run in a publicly available site in order to avoid unauthorized people from abusing the email system, as there is no authentication and authorization involved in the page. 
<hr>
<%
String hostname = "your-smtp-host-please-change";
if (request.getParameter("sender")==null)
{
%>
<HTML>
<HEAD>
<TITLE>SendMail Sample with serverside attachments</TITLE>
</HEAD>

<FORM METHOD="POST">
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="30%">
<TR><TD>From:</TD><TD><INPUT TYPE="text" name="sender" ></TD></TR>
<TR><TD>To:</TD><TD><INPUT TYPE="text" name="recipient" ></TD></TR>
<TR><TD>Cc:</TD><TD><INPUT TYPE="text" name="cc" ></TD></TR>
<TR><TD>Bcc:</TD><TD><INPUT TYPE="text" name="bcc" ></TD></TR>
<TR><TD>Subject:</TD><TD><INPUT TYPE="text" name="subject" VALUE="Hi"> </TD></TR>
</TABLE>
<HR>
Server Attachment: <INPUT TYPE="text" name="serverAttachment" > <i>(use when attaching files that currently reside on the same machine as the JSP runtime)</i> 
<br>
<HR>
<TEXTAREA name="body" ROWS=4 COLS=30>How are you!</TEXTAREA><br><br>
<HR>
<INPUT TYPE="submit" value="Send">
</FORM>
<%
}
else
{
%>
<BODY BGCOLOR="#FFFFFF">
<P>Result:

       <mail:sendMail host='<%=hostname%>'
             sender='<%=request.getParameter("sender")%>'
             recipient='<%=request.getParameter("recipient")%>'
             cc='<%=request.getParameter("cc")%>'
             bcc='<%=request.getParameter("bcc")%>'
             subject='<%=request.getParameter("subject")%>'
             serverAttachment='<%=request.getParameter("serverAttachment")%>'>
             <%=request.getParameter("body")%>
       </mail:sendMail>
<HR>
The following email was sent out successfully!<br>
host='<%=util.HTMLReplace(hostname)%>'<br>
sender='<%=util.HTMLReplace(request.getParameter("sender"))%>'<br>
recipient='<%=util.HTMLReplace(request.getParameter("recipient"))%>'<br>
cc='<%=util.HTMLReplace(request.getParameter("cc"))%>'<br>
bcc='<%=util.HTMLReplace(request.getParameter("bcc"))%>'<br>
subject='<%=util.HTMLReplace(request.getParameter("subject"))%>'<br>
<%
if (request.getParameter("serverAttachment")==null)
{
%>
Attachments:none
<%
}
if (!(request.getParameter("serverAttachment")==null))
{
%>
serverAttachment='<%=util.HTMLReplace(request.getParameter("serverAttachment"))%>'<br>
<%
}
%>
body='<%=util.HTMLReplace(request.getParameter("body"))%>'<br>
<HR>
</BODY>
<%
}
%>
</HTML>

