Example 2 Specifying an Initial Message Header
The program shown in Example 7–2 illustrates
the use of the MTA_HDRMSG_FILE and MTA_HDR_ADRS item
codes to enqueue a message that has already been composed, including the headers,
and stored in a file. The input file is given in the Input File for Example 2 Specifying an Initial Message Header. The resulting message
is shown in Output for Example 2 Specifying an Initial Message Header.
When the entire message, header and body, is contained in a single file, use
the MTA_HDRMSG_FILE item code in place of the MTA_HDR_FILE and MTA_MSG_FILE item codes.
Example 7–2 Specify an Initial Message Header
/* send_header.c -- Send a message with initial header */
#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[3];
int index = 0;
ITEM(MTA_HDR_ADRS, 0);
ITEM(MTA_HDRMSG_FILE, "send_header.txt");
ITEM(MTA_END_LIST, 0);
exit(mtaSend(item_list));
}
|
Input File for Example 2 Specifying an Initial Message Header
Subject: MTA SDK callable Send example
To: root@sesta.com
MIME-version: 1.0
Content-type: TEXT/PLAIN; CHARSET=US-ASCII
Content-transfer-encoding: 7BIT
Comments: Ignore this message -- it’s just a test
This is a test of the emergency broadcasting system!
1234567890123456789012345678901234567890123456789012345678901234
5678901234567890
0000000001111111111222222222233333333334444444444555555555566666
6666677777777778
|
Output for Example 2 Specifying an Initial Message Header
Date: 04 Jan 2003 22:42:25 -0800 (PST)
From: system@sesta.com
Subject: MTA SDK callable Send example
To: system@sesta.com
Message-id: <01GPKFNPUQF89LV1WX@sesta.com\>
MIME-version: 1.0
Content-type: TEXT/PLAIN; CHARSET=US-ASCII
Content-transfer-encoding: 7BIT
Comments: Ignore this message -- it’s just a test
This is a test of the emergency broadcasting system!
1234567890123456789012345678901234567890123456789012345678901234
5678901234567890
0000000001111111111222222222233333333334444444444555555555566666
6666677777777778
|