Small HTTP server
ver 2.04 / ver 3.0364

|News| |Description| |Get 2.04(70 Kb) / 3.0364(91 Kb)| |Registration| |Home| |Forum| |License|


Sendmail for Small HTTP server.

Often incompotible between scripts under Unix and under Windows is the absence of "sendmail" program and sometimes the absence of "popen" function. It's easy to decide this problem under Small HTTP server. Just enable SMTP server, option it, and create files with messages in OUTBOX directory. The name of this files must be generated by next format "%8.8X.msg" First line of this file must have next format:
From return@address (from_server [##.##.##.##]) Date For destination@address
e.g.
From myscript@host.com (via Web [127.0.0.1]) Wed, 9 Jan 2002 21:16:46 GMT For admin@host.com
If "popen" function is avilable in your script, you can use easy Sendmail emulator (download 4 Kb). This program must be placed in directory upper then OUTBOX or you must use key "-o" to direct OUTBOX location. (In server's options SMTP must be enabled, and full path for OUTBOX is hard recomended, to send messages immediatle) Command line:
sendmail {Keys} [to@address]
Next keys are supported:
-t  -- read recipients from message
-o d:\outbox\foulder  -- OUTBOX subderectory in Small HTTP server
-f from@address
-F full name
-s  -- save From lines in headers

Other keys are ignored.
to@address or key -t must be.
You can write your own replacement of sendmail. Here is an example on C of function that replace popen("/usr/bin/sendmail -t","w"):

#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>

const char outbox[]="..\\..\\outbox"; // Here you must direct your path to OUTBOX.


FILE * sendmail(char *from,char *to)
{
 char bfr[512];
 int  t;
 FILE *r;
 struct stat st;

 t=time();
 do{          // find uniq file name.
  sprintf(bfr,"%s\\%8.8X.msg",outbox,--t);
 }while( stat(bfr,&st)!=-1 )
 r=fopen(bfr,"w");
 fprintf(r,"From %s (via Web [%s]) %s For %s\n",
         from, getenv("REMOTE_ADDR"), getenv("DATE_GMT"), to);
 return r;
};

|News| |Description| |Get 2.04(70 Kb) / 3.0364(91 Kb)| |Registration| |Home| |Forum| |License|