<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Jaggery - Delicious Javascript</title>
    <meta name="description" content="">
    <meta name="author" content="">

    <!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
    <!--[if lt IE 9]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->

    <!-- Le styles -->
    <link href="../css/bootstrap.css" rel="stylesheet">
    <style type="text/css">
        body {
            padding-top: 60px;
        }
    </style>
    <link href="../css/prettify.css" rel="stylesheet">
    <!-- Le fav and touch icons -->
    <link rel="shortcut icon" href="../images/favicon.ico">
    <link rel="apple-touch-icon" href="../images/apple-touch-icon.png">
    <link rel="apple-touch-icon" sizes="72x72"
          href="../images/apple-touch-icon-72x72.png">
    <link rel="apple-touch-icon" sizes="114x114"
          href="../images/apple-touch-icon-114x114.png">
</head>

<body>

<%
include('/includes/topnavi.jag');
%>

<div class="container-fluid" style="width: 960px; margin: auto;">
<div class="row">
    <div class="span16">
        <div class="page-header">
            <h1  id="top">
                Documentation
                <small>API documentation for Jaggery.js</small>
            </h1>
        </div>
    </div>
</div>

<div class="row">
<div class="span4">
    <div class="well">
        <%
        include('/includes/navi.jag');
        %>

    </div>

</div>
<div class="span12">
<div class="content" id="email" name="email">
<h3>Sender</h3>

<pre class="prettyprint linenums">
&lt%

    var content = request.getParameter("cont");
    var to = request.getParameter("to");
    var subject = request.getParameter("sub");

    var email = require('email');
    var sender = new msg.Sender("smtp.gmail.com", "25", "username", "password", "tls");

    sender.from = "";
    sender.to = to;
    sender.cc = "";
    sender.bcc = "";
    sender.subject = subject;
    sender.text = content;
    sender.send();

    print("email successfully sent to " + to);
%&gt
</pre>
<%

var emailCode = '&lt% \n var content = request.getParameter("cont");'
+ '\n var to = request.getParameter("to");'
+ '\n var subject = request.getParameter("sub");'
+ '\n '
+ '\n var email = require("email");'
+ '\n //Add valid credentials'
+ '\n var sender = new email.Sender("smtp.gmail.com", "25", "username", "password");'
+ '\n '
+ '\n //Fill the correct information'
+ '\n sender.from = "";'
+ '\n sender.to = to;'
+ '\n sender.cc = "";'
+ '\n sender.bcc = "";'
+ '\n sender.subject = subject;'
+ '\n sender.text = content;'
+ '\n sender.send();'
+ '\n '
+ '\n print("email successfully sent to " + to); \n %&gt';

var codeSnip = encodeURIComponent(emailCode);
var urlString = '../tryitframe.jag?code='+codeSnip;

include('/includes/tryit_but.jag');
%>

<div id="pageLinks">
<a class="navilink" href="#overview">Overview</a>
<a class="navilink" href="#members">Members</a>
<a class="navilink" href="#operations">Operations</a>
</div>

<section id="overview">  
 	
<h4>Overview</h4>
<p class="description">The Sender Object allows users to send out email from their apps.</p>

</section>	
	
<section id="members">	
<h4>Members</h4>


<table class="clsStd member-table">

    <tbody>

    <tr>
		<th>Member</th>
		<th>&nbsp;&nbsp;Type&nbsp;&nbsp;</th>
		<th>Description</th>
	</tr>

    <tr>

        <td><code>from</code></td>
        <td>String</td>
        <td><pre class="prettyprint">sender.from = "madhuka@wso2.com"; </pre>
            
            An optional property to set the "from" address of the
            email to be sent. If not set the user account used to
            authenticate against the email gateway will be sent as the
            "from" address.
            <br>
        </td>

    </tr>

     <tr>

        <td><code>to </code></td>
         <td>String or Array</td>
        <td>

            <pre class="prettyprint">sender.to = "nuwan@wso2.com"; </pre>

            <pre class="prettyprint">
var to = new Array();
to[0] = "nuwan@wso2.com";
to[1] = "teague@wso2.com";
sender.to = to; </pre>
            This is a required property that denotes the "to"
            address of the email to be sent. (Optionally an array of
            strings denoting the "to" addresses can be passed as above.)


        </td>

    </tr>
    <tr>

        <td><code>cc </code></td>
        <td> String or Array</td>
        <td> <pre class="prettyprint">sender.cc = "madhuka@wso2.com"; </pre>
           
<pre class="prettyprint">
var cc = new Array();
cc[0] = "nuwan@wso2.com";
cc[1] = "teague@wso2.com";
sender.cc= cc; </pre>

            This is an optional property that denotes the "cc"
            address of the email to be sent. (Optionally an array of
            strings denoting the "cc" addresses can be passed as above.)

        </td>

    </tr>
    <tr>

           <td><code>bcc</code></td>
           <td>String or Array</td>
           <td>
               <pre class="prettyprint">sender.bcc = "jhon@wso2.com"; </pre>
               <pre class="prettyprint"> var bcc = new Array();
    bcc[0] = "jonathan@wso2.com";
    bcc[1] = "nuwan@wso2.com";
    sender.bcc = bcc; </pre>
               This is an optional property that denotes the "bcc"
               address of the email to be sent. (Optionally an array of
               strings denoting the "bcc" addresses can be passed as below.)


           </td>

       </tr>
    
   <tr>

        <td><code>subject</code></td>
          <td>String</td>
        <td>
            <pre class="prettyprint">sender.subject = "WSO2 Jaggery on Released";</pre>
            An optional property to set the subject of the email to
            be sent.
        </td>

    </tr>
    <tr>

        <td><code>text</code></td>
         <td>String</td>
        <td>
            <pre class="prettyprint">sender.text = "Jaggery goes on live from 2012"; </pre>
            An optional property to set the body text of the email
            to be sent.

        </td>

    </tr>

    <tr>
        <td><code>html</code></td>
        <td>String or XML Object</td>
        <td>
           <pre class="prettyprint"> sender.html = "&lt;h1&gt;Jaggery was Released on January 2012&lt;/h1&gt;";
										// Setthing the HTML content as a String </pre>
             <pre class="prettyprint">sender.html = &lt;h1&gt;Jaggery was Released on January 2012&lt;/h1&gt;;
										// Setting the HTML content as an XML object </pre>
            An optional property to set the body of the email to be
            sent. This function can be used to send HTML mail.

        </td>
    </tr>
	</tbody>
</table><!-- /members table -->

</section>

<section id="operations">
<h4>Operations</h4>
<table class="clsStd operations-table">

    <tbody>

    <tr>

        <th>Operations</th>
       <th>Returns</th>
        <th>Description</th>

    </tr>

    <tr>

        <td><code>Sender()</code></td>
        <td>None</td>
        <td>
            <pre class="prettyprint">
var sender = new email.Sender("smtp.example.com", "25", "username@example.com", "password");
                    </pre>
            <br/>
            <pre class="prettyprint">
var sender = new email.Sender("smtp.gmail.com", "25", "username@gmail.com", "password", "tls");
                    </pre>
            Adding <code>"tls"</code> as the fifth argument will enable TLS for the communication<br>
            

        </td>

    </tr>
   
    <tr>

        <td><code>addAttachment([String filePath] [FileHostObject file]) </code>
        </td>
       <td>None</td>
        <td><pre class="prettyprint">
var file = new File("temp.txt"); // A file exists at temp.txt
sender.addAttachement(file, "temp.txt");
            </pre>
        An optional property to add attchments to the email
            been sent. This function has a variable number of arguments,
            each argument can be a File hostObject or a string representing
            a file.

        </td>

    </tr>

    <tr>

        <td><code>send() </code>
        </td>
        <td>None</td>
        <td>Used to send the email.</td>

    </tr>

    </tbody>
</table>
</section>
</div>
<!-- /email div -->
<br>
<br>
</div>

</div>
<%
include('/includes/footer.jag');
%>


</div>
<!-- /container -->
<%
include('/includes/scripts.jag')
%>

	<script>	
		
		$(document).ready(function(){
        $('#email').toggleClass('active')
		$('#docs').addClass('active')
        });
		
	
		    
		
	</script>
	
</body>
</html>