Sun Java System Messaging Server 6 2005Q4 MTA Developer's Reference

Sending a Simple Message

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.

Example 7–1 Send a Simple Message

/* 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 */

Output for Example 1 Sending a Simple Message

Date: 04 Oct 1992 22:24:07 -0700 (PDT)
Subject: send_simple.c
Message-id: <\>
MIME-version: 1.0
Content-transfer-encoding: 7BIT

/* send_simple.c -- Send a simple message */
#include <string.h\>
#include "mtasdk.h"