The program shown in Example 7–1 demonstrates how to send a simple message to the root account. The source code itself is used as the input source for the body of the message to be sent. The From: address associated with the message is that of the process running the program. Comments in the program example explain the sample output line they generate.
/* send_simple.c Send a simple message */ #include <string.h\> #include "mtasdk.h" /* Push an entry onto the item list */ #define ITEM(item,adr) item_list[index].item_code = item;\ item_list[index].item_address = adr;\ item_list[index].item_length = adr ? strlen(adr) : 0; \ item_list[index].item_status = 0;\ item_list[index++].item_smessage = NULL main () { mta_item_list_t item_list[4]; int index = 0; ITEM(MTA_TO, "root"); /* Becomes the To: line in the output */ ITEM(MTA_SUBJECT, "send_simple.c"); ITEM(MTA_MSG_FILE, __FILE__);/* Becomes the Subject: line */ ITEM(MTA_END_LIST, 0); exit(mtaSend(item_list)); } |
Date: 04 Oct 1992 22:24:07 -0700 (PDT) From: jdoe@sesta.com Subject: send_simple.c To: root@sesta.com Message-id: <01GPKF10JIB89LV1WX@sesta.com\> MIME-version: 1.0 Content-type: TEXT/PLAIN; CHARSET=US-ASCII Content-transfer-encoding: 7BIT /* send_simple.c -- Send a simple message */ #include <string.h\> #include "mtasdk.h" ... |