Index: /trunk/FACT++/scripts/doc/Mail.js
===================================================================
--- /trunk/FACT++/scripts/doc/Mail.js	(revision 15172)
+++ /trunk/FACT++/scripts/doc/Mail.js	(revision 15172)
@@ -0,0 +1,114 @@
+throw new Error("Description for built in functions. Must not be included!");
+/**
+ * @fileOverview
+ *    A class which allows to send mails through the 'mail' program
+ */
+
+
+/**
+ * @class
+ *
+ * This class represents an interface to the program 'mail'
+ *
+ * To send a mail, create an instance and fill the properties
+ * (see reference) with proper data.
+ *
+ * @example
+ *     var mail = new Mail("This is the subject");
+ *
+ *     // At least one recipient is mandatory
+ *     mail.recipients.push("max.mustermann@musterstadt.com");
+ *     // To add several recipients
+ *     mail.recipients.push("max.mustermann@musterstadt.com", "erika.mustermann@musterstadt.com");
+ *
+ *     // similar to the property recipient you can use the properties 'cc' and 'bcc'
+ *
+ *     // If you want to add attachments [optional]
+ *     mail.attachments.push("logfile.txt");
+ *     // or for several attachments
+ *     mail.attachments.pus("logfile1.txt", "logfile2.txt");
+ *
+ *     // The text of the message is set in the property text...
+ *     // ...either as single string
+ *     mail.text.push("This is line1\nThis is line2");
+ *     mail.text.push("This is line1");
+ *     mail.text.push("This is line2");
+ *
+ *     // Send the message
+ *     mail.send();
+ *
+ * @author <a href="mailto:thomas.bretz@epfl.ch">Thomas Bretz</a>
+ *
+ */
+function Sky()
+{
+
+    /**
+     * Subject of the mail
+     *
+     * @type String
+     */
+    this.subject = subject;
+
+    /**
+     * Recipient(s) of the mail. One recipient is mandatory.
+     *
+     * @type Array[String]
+     */
+    this.recipients = recipient;
+
+    /**
+     * Carbon copy [optional]. Adresses who should receive a copy of the
+     * mail. All entries in the array which are not a string are silently ignored.
+     *
+     * @type Array[String]
+     */
+    this.cc = undefined;
+
+    /**
+     * Blind carbon copy [optional]. Adresses who should receive a copy of the
+     * mail. All entries in the array which are not a string are silently ignored.
+     *
+     * @type Array[String]
+     */
+    this.bcc = undefined;
+
+    /**
+     * Attachments [optional]. File to be attached to the mail.
+     * All entries in the array which are not a string are silently ignored.
+     *
+     * @type Array[String]
+     */
+    this.attachments = undefined;
+
+    /**
+     * Message body. At least one line in the message is mandatory.
+     * Undefined or null entries in the array are silently ignored.
+     *
+     * @type Array[String]
+     */
+    this.text = text;
+
+    /**
+     * Send the message. This calles the 'mailx' program. For further
+     * details, e.g. on the return value, see the corresponding man page.
+     *
+     * @param {Boolean} [block=true]
+     *    This parameter specifies whether the pipe should be closed,
+     *    which means that a blocking wait is performed until the 'mail'
+     *    program returns, or the pipe will be closed automatically
+     *    in the background when the 'mail' program has finished.
+     *    Note, that if the calling program terminates, maybe this
+     *    call will never succeed.
+     *
+     * @returns {Integer}
+     *    The return code of the 'mail' program is returned (0
+     *    usually means success), undefined if block was set to false.
+     *
+     * @throws
+     *    An exception is thrown if any validity check for the
+     *    properties or the arguments fail.
+     *
+     */
+    this.send = function() { /* [native code] */ }
+}
Index: /trunk/FACT++/src/InterpreterV8.cc
===================================================================
--- /trunk/FACT++/src/InterpreterV8.cc	(revision 15171)
+++ /trunk/FACT++/src/InterpreterV8.cc	(revision 15172)
@@ -775,34 +775,49 @@
         return ThrowException(String::New("Mail must be called as constructor"));
 
+    if (args.Length()!=1 || !args[0]->IsString())
+        return ThrowException(String::New("Constructor must be called with a single string as argument"));
+
     HandleScope handle_scope;
 
+    Handle<Array> rec = Array::New();
+    Handle<Array> att = Array::New();
+    Handle<Array> bcc = Array::New();
+    Handle<Array> cc  = Array::New();
+    Handle<Array> txt = Array::New();
+    if (rec.IsEmpty() || att.IsEmpty() || bcc.IsEmpty() || cc.IsEmpty() || txt.IsEmpty())
+        return Undefined();
+
     Handle<Object> self = args.This();
+
+    self->Set(String::New("subject"),     args[0]->ToString(), ReadOnly);
+    self->Set(String::New("recipients"),  rec, ReadOnly);
+    self->Set(String::New("attachments"), att, ReadOnly);
+    self->Set(String::New("bcc"),         bcc, ReadOnly);
+    self->Set(String::New("cc"),          cc,  ReadOnly);
+    self->Set(String::New("text"),        txt, ReadOnly);
+
     self->Set(String::New("send"), FunctionTemplate::New(WrapSendMail)->GetFunction(), ReadOnly);
+
     return handle_scope.Close(self);
 }
 
-vector<string> InterpreterV8::ValueToArray(const Handle<Value> &val)
+vector<string> InterpreterV8::ValueToArray(const Handle<Value> &val, bool only)
 {
     vector<string> rc;
-    if (val->IsString())
-    {
-        rc.push_back(*String::AsciiValue(val->ToString()));
-        return rc;
-    }
-
-    if (val->IsArray())
-    {
-        Handle<Array> arr = Handle<Array>::Cast(val);
-        for (uint32_t i=0; i<arr->Length(); i++)
-        {
-            Handle<Value> obj = arr->Get(i);
-            if (obj.IsEmpty())
-                continue;
-
-            if (!obj->IsString())
-                return vector<string>();
-
-            rc.push_back(*String::AsciiValue(obj->ToString()));
-        }
+
+    Handle<Array> arr = Handle<Array>::Cast(val);
+    for (uint32_t i=0; i<arr->Length(); i++)
+    {
+        Handle<Value> obj = arr->Get(i);
+        if (obj.IsEmpty())
+            continue;
+
+        if (obj->IsNull() || obj->IsUndefined())
+            continue;
+
+        if (only && !obj->IsString())
+            continue;
+
+        rc.push_back(*String::AsciiValue(obj->ToString()));
     }
 
@@ -823,15 +838,12 @@
 
     const Handle<Value> sub = args.This()->Get(String::New("subject"));
-    const Handle<Value> rec = args.This()->Get(String::New("recipient"));
+    const Handle<Value> rec = args.This()->Get(String::New("recipients"));
     const Handle<Value> txt = args.This()->Get(String::New("text"));
-    const Handle<Value> att = args.This()->Get(String::New("attachment"));
+    const Handle<Value> att = args.This()->Get(String::New("attachments"));
     const Handle<Value> bcc = args.This()->Get(String::New("bcc"));
     const Handle<Value> cc  = args.This()->Get(String::New("cc"));
 
-    if (sub->IsUndefined())
-        return ThrowException(String::New("Required property 'subject' missing."));
-
     const vector<string> vrec = ValueToArray(rec);
-    const vector<string> vtxt = ValueToArray(txt);
+    const vector<string> vtxt = ValueToArray(txt, false);
     const vector<string> vatt = ValueToArray(att);
     const vector<string> vbcc = ValueToArray(bcc);
@@ -839,19 +851,9 @@
 
     if (vrec.size()==0)
-        return ThrowException(String::New("Required property 'recipient' must be a string or an array of strings."));
+        return ThrowException(String::New("At least one valid string is required in 'recipients'."));
     if (vtxt.size()==0)
-        return ThrowException(String::New("Required property 'text' must be a string or an array of strings."));
-    if (vatt.size()==0 && !att->IsUndefined())
-        return ThrowException(String::New("Property 'attachment' must be a string or an array of strings."));
-    if (vbcc.size()==0 && !bcc->IsUndefined())
-        return ThrowException(String::New("Property 'bcc' must be a string or an array of strings."));
-    if (vcc.size()==0 && !cc->IsUndefined())
-        return ThrowException(String::New("Property 'cc' must be a string or an array of strings."));
-
-    if (!sub->IsString())
-        return ThrowException(String::New("Property 'subject' must be a string."));
+        return ThrowException(String::New("At least one valid string is required in 'text'."));
 
     const string subject = *String::AsciiValue(sub->ToString());
-
 
     FILE *pipe = popen(("from=no-reply@fact-project.org mailx -~ "+vrec[0]).c_str(), "w");
@@ -2389,5 +2391,5 @@
     fTemplateDescription = desc;
 
-#ifdef HAVE_MAIL
+#ifdef HAVE_MAILX
     Handle<FunctionTemplate> mail = FunctionTemplate::New(ConstructorMail);
     mail->SetClassName(String::New("Mail"));
Index: /trunk/FACT++/src/InterpreterV8.h
===================================================================
--- /trunk/FACT++/src/InterpreterV8.h	(revision 15171)
+++ /trunk/FACT++/src/InterpreterV8.h	(revision 15172)
@@ -64,5 +64,5 @@
     void Thread(int &id, v8::Persistent<v8::Function> func, uint32_t ms);
 
-    std::vector<std::string> ValueToArray(const v8::Handle<v8::Value> &val);
+    std::vector<std::string> ValueToArray(const v8::Handle<v8::Value> &val, bool only=true);
 
     v8::Handle<v8::Value> FuncWait(const v8::Arguments& args);
