开发者

Sending logs via email using serverside javascript

I need to build a Javascript which scans a directory regularly and emails the log files to a group of people

I am not familiar with all Javascript frameworks, but from what I know client side javascript does not allow you to send an email without help from a client email application(like Outlook Express and such).

  1. Are there any Javascript frameworks which provide such functionality via some API?
  2. If there are no Javascript frameworks, can I use serverside Javascript to do what I want.

I am familiar with basic JavaScript (no frameworks and don't know anything about serverside JavaScript).

My rudimentary code is

function sendemail()
{
    var emailaddresses = ["address1@domain.com","address2@domain.com"..."addressn@domain.com"];
    /* list of email addresses to receive log files */

    // Assuming the log file is in C:\test, though it can be on a network location onanother server also
    var file=fopen("C:\\test\\log file.txt",0);
    var len = flength(file);
    var str = fread(file,len);
    fwrite(file, str);

    var href = "mailto:" + emailaddresses.splice(0, 1) + "?"
        + "cc=" + emailaddresses.join(",") + "&"
        + "subject= log files" + "&"
        + "body=Attached are the logs" + str;

    var windowMail = window.open(href, "_blank", "scrollbars=yes,resizable=yes,width=10,height=10");
    if开发者_高级运维( windowMail )
    {
        windowMail.close();
    }
}

It is not working and certainly does not attach the logs(but copies their content into a variable and send the content as body of message which can cause issues with lot of mail clients like Outlook Express)

Did enough search to learn client side Javascript is not suited for this task as server side language such as PHP, ASP

Some links mention how to attach a file http://www.codeproject.com/KB/scripting/Exsead8.aspx and http://arstechnica.com/open-source/news/2009/11/w3c-publishes-draft-of-new-file-api-spec.ars , but I want to know if there is another way using some framework API or serverside javascript.

Any suggestions would be appreciated.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜