<%@ Language=vb_script%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- Kod Skripte -->
<%
mes = ""
IsSuccess = false

sTo = "mrbranko@gmail.com" <!-- unesite email adresu na koju zelite da primate mail sa forme -->
sFrom = Trim(Request.Form("txtFrom"))
sSubject = Trim(Request.Form("txtSubject"))
sMailServer = "127.0.0.1" <!-- unesite IP adresu Vaseg Hosting servera -->
sBody = Trim(Request.Form("txtBody")) + " " + Trim(Request.Form("txtFrom")) + " " + Trim(Request.Form("txtSubject"))

if Request("__action")="TestEMail" then
	TestEMail()	
end if

Sub TestEMail()

	Set objMail = Server.CreateObject("CDO.Message")
	Set objConf = Server.CreateObject("CDO.Configuration") 
	Set objFields = objConf.Fields
	
	With objFields
		.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
		.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")  = sMailServer 
		.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10 
		.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
		.Update 
	End With

	With objMail
		Set .Configuration = objConf
		.From = sFrom
		.To = sTo
		.Subject = sSubject
		.TextBody = sBody
	End With
    
    Err.Clear 
	on error resume next

   objMail.Send
	if len(Err.Description) = 0 then
        mes = " The message was sent to " + sTo
        mes = mes + " "
        IsSuccess = true
    else
		mes = " " + Err.Description + " The mail sending test failed."
	end if
	Set objFields = Nothing
	Set objConf = Nothing
	Set objMail = Nothing
End sub

Sub Alert(html)
	if IsSuccess then
		Response.Write "<div class='testRelults' id='testSuccessful'><span class='testResult'>Success:</span>" & html & "</div>"
	else
		Response.Write "<div class='testRelults' id='testFailed'><span class='testResult'>Failure:</span>" & html & "</div>"
	end if
End Sub
%>
<!-- HTML kod -->
<span><p>
<head>
	<title>Mail Sender Form</title>
</head>

<tr><td><p>
	<form id="form1" action="MailSend.asp?__action=TestEMail&tp=<%= rnd(1)*100*timer %>" method="POST" > <!-- unesite naziv stranice na kojoj ce se izvrsavati forma (umesto 'MailSend.asp') -->
   	<input id="__action" type="hidden" value="" />                  
      
      <div class="formContainer">
         	<% if len(mes) > 0 then	Alert(mes) end if %>
           	<fieldset>
           	<legend id="LegendName">MailSend Form</legend>
            	<p>
               	<table class="formFields" cellspacing="0" width="100%">
                  	<tr>
                     	<td class="name">
                        	<label for="txtFrom">From</label></td>
                        <td>
                        	<input name="txtFrom" size="25" value = "<% Response.Write(sFrom) %>">
                        </td>
                  	</tr>
                     <tr>
                     	<td class="name">
                        	<label for="txtSubject">Subject</label>
                        </td>
                        <td>
                        	<input name="txtSubject" size="25" value="<% Response.Write(sSubject) %>">
                        </td>
                   	</tr>
                     <tr>
                     	<td class="name">
                        	<label for="txtBody">Message body</label>
                        </td>
                        <td rowspan="2">
 									<textarea name="txtBody" cols = "35" rows="4"><% Response.Write(sBody) %></textarea>
                        </td>
                    	</tr>
               	 </table>
 					</p>
           	</fieldset>
        		<div>
        			<button type="submit" name="bname_ok">Posalji</button>
				</div>                            
      </div>
	</form>
</td></tr>
</span>