Topic: C mail() function
Author: harry#d#.tempelman@canrem.com (Harry. Tempelman)
Date: Fri, 17 Sep 93 08:50:00 -0400 Raw View
Question: How can change the program with the C mail command?
like mail(addr,subj,mesg)
/* Mail program for Aix
by
Harry Tempelman
Compiler : Aix RS/6k cc
Machine : AIX 340
Date : 16-SEP-93 */
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <string.h>
#include <time.h>
#include <sys/param.h>
#include <unistd.h>
void main(void);
void main(void)
{
FILE *fp;
char hostname[]= "APEX", user1[]= "operator", user2[]= "root";
char subj[]= "TimeOut_program";
char TmpFile[]= "/tmp/TmpMail";
char invoker[80];
char addr[125];
char mesg[125];
char Cmd[255];
char *s;
struct tm *p_tm;
time_t t;
time ( &t );
strcpy(invoker, getlogin( ) );
sprintf( mesg,"\n\tLogged out user %s on %s\n\n",invoker, asctime( localtime(&t)) );
sprintf( addr,"%s@%s %s@%s",user1, hostname, user2, hostname );
fp = fopen( TmpFile,"w" );
fprintf( fp, "%s\n",mesg );
fclose( fp );
sprintf( Cmd,"Mail -s %s %s </tmp/TmpMail", subj, addr );
system( Cmd );
remove(TmpFile);
}
APEX METALS INC. . . . . __|__ . . harry.tempelman@canrem.com
. . . . . . . --o--o--(_)--o--o-- . . . . . . . .
---
DeLuxe 1.25 #11534 REALITY.SYS Corrupted: Reboot universe? [Y/N]