libmilter/mfapi.h

libmilter/mfapi.h — libmilter compatible API.

Synopsis

#define             SMFI_VERSION
#define             SM_LM_VRS_MAJOR                     (version)
#define             SM_LM_VRS_MINOR                     (version)
#define             SM_LM_VRS_PLVL                      (version)
#define             MI_SUCCESS
#define             MI_FAILURE
typedef             SMFICTX;
typedef             SMFICTX_PTR;
typedef             smfiDesc_str;
typedef             smfiDesc_ptr;
typedef             sfsistat;
#define             bool
#define             true
#define             false
sfsistat            xxfi_connect                        (SMFICTX *context,
                                                         char *host_name,
                                                         _SOCK_ADDR *address);
sfsistat            xxfi_helo                           (SMFICTX *context,
                                                         char *fqdn);
sfsistat            xxfi_envfrom                        (SMFICTX *context,
                                                         char **arguments);
sfsistat            xxfi_envrcpt                        (SMFICTX *context,
                                                         char **arguments);
sfsistat            xxfi_header                         (SMFICTX *context,
                                                         char *name,
                                                         char *value);
sfsistat            xxfi_eoh                            (SMFICTX *context);
sfsistat            xxfi_body                           (SMFICTX *context,
                                                         unsigned char *data,
                                                         size_t data_size);
sfsistat            xxfi_eom                            (SMFICTX *context);
sfsistat            xxfi_abort                          (SMFICTX *context);
sfsistat            xxfi_close                          (SMFICTX *context);
sfsistat            xxfi_unknown                        (SMFICTX *context,
                                                         const char *command);
sfsistat            xxfi_data                           (SMFICTX *context);
sfsistat            xxfi_negotiate                      (SMFICTX *context,
                                                         unsigned long  actions,
                                                         unsigned long  steps,
                                                         unsigned long  unused0,
                                                         unsigned long  unused1,
                                                         unsigned long *actions_output,
                                                         unsigned long *steps_output,
                                                         unsigned long *unused0_output,
                                                         unsigned long *unused1_output);
int                 smfi_opensocket                     (bool remove_socket);
int                 smfi_register                       (struct smfiDesc description);
int                 smfi_main                           (void);
int                 smfi_setbacklog                     (int backlog);
int                 smfi_setdbg                         (int level);
int                 smfi_settimeout                     (int timeout);
int                 smfi_setconn                        (char *connection_spec);
int                 smfi_stop                           (void);
int                 smfi_version                        (unsigned int *major,
                                                         unsigned int *minor,
                                                         unsigned int *patch_level);
#define             SMFIF_ADDHDRS
#define             SMFIF_CHGBODY
#define             SMFIF_MODBODY
#define             SMFIF_ADDRCPT
#define             SMFIF_DELRCPT
#define             SMFIF_CHGHDRS
#define             SMFIF_QUARANTINE
#define             SMFIF_CHGFROM
#define             SMFIF_ADDRCPT_PAR
#define             SMFIF_SETSYMLIST
#define             SMFIS_CONTINUE
#define             SMFIS_REJECT
#define             SMFIS_DISCARD
#define             SMFIS_ACCEPT
#define             SMFIS_TEMPFAIL
#define             SMFIS_NOREPLY
#define             SMFIS_SKIP
#define             SMFIS_ALL_OPTS
#define             SMFIM_CONNECT
#define             SMFIM_HELO
#define             SMFIM_ENVFROM
#define             SMFIM_ENVRCPT
#define             SMFIM_DATA
#define             SMFIM_EOM
#define             SMFIM_EOH
#define             SMFIP_NOCONNECT
#define             SMFIP_NOHELO
#define             SMFIP_NOMAIL
#define             SMFIP_NORCPT
#define             SMFIP_NOBODY
#define             SMFIP_NOHDRS
#define             SMFIP_NOEOH
#define             SMFIP_NR_HDR
#define             SMFIP_NOHREPL
#define             SMFIP_NOUNKNOWN
#define             SMFIP_NODATA
#define             SMFIP_SKIP
#define             SMFIP_RCPT_REJ
#define             SMFIP_NR_CONN
#define             SMFIP_NR_HELO
#define             SMFIP_NR_MAIL
#define             SMFIP_NR_RCPT
#define             SMFIP_NR_DATA
#define             SMFIP_NR_UNKN
#define             SMFIP_NR_EOH
#define             SMFIP_NR_BODY
#define             SMFIP_HDR_LEADSPC
char*               smfi_getsymval                      (SMFICTX *context,
                                                         char *name);
int                 smfi_setreply                       (SMFICTX *context,
                                                         char *return_code,
                                                         char *extended_code,
                                                         char *message);
int                 smfi_setmlreply                     (SMFICTX *context,
                                                         const char *return_code,
                                                         const char *extended_code,
                                                         ...);
int                 smfi_addheader                      (SMFICTX *context,
                                                         char *name,
                                                         char *value);
int                 smfi_chgheader                      (SMFICTX *context,
                                                         char *name,
                                                         int index,
                                                         char *value);
int                 smfi_insheader                      (SMFICTX *context,
                                                         int index,
                                                         char *name,
                                                         char *value);
int                 smfi_chgfrom                        (SMFICTX *context,
                                                         char *mail,
                                                         char *arguments);
int                 smfi_addrcpt                        (SMFICTX *context,
                                                         char *recipient);
int                 smfi_addrcpt_par                    (SMFICTX *context,
                                                         char *recipient,
                                                         char *arguments);
int                 smfi_delrcpt                        (SMFICTX *context,
                                                         char *recipient);
int                 smfi_progress                       (SMFICTX *context);
int                 smfi_replacebody                    (SMFICTX *context,
                                                         unsigned char *new_body,
                                                         int new_body_size);
int                 smfi_quarantine                     (SMFICTX *context,
                                                         char *reason);
int                 smfi_setpriv                        (SMFICTX *context,
                                                         void *data);
void*               smfi_getpriv                        (SMFICTX *context);
int                 smfi_setsymlist                     (SMFICTX *context,
                                                         int state,
                                                         char *macros);

Description

libmilter/mfapi.h provides Sendmail's libmilter compatible API. You can use this library instead of Sendmail's libmilter. See also API Documentation on milter.org.

Details

SMFI_VERSION

#  define SMFI_VERSION	0x01000001

libmilter version number.


SM_LM_VRS_MAJOR()

#define SM_LM_VRS_MAJOR(version)	(((version) & 0x7f000000) >> 24)

Extracts major version number from version.

version :

the version number.

SM_LM_VRS_MINOR()

#define SM_LM_VRS_MINOR(version)	(((version) & 0x007fff00) >> 8)

Extracts minor version number from version.

version :

the version number.

SM_LM_VRS_PLVL()

#define SM_LM_VRS_PLVL(version)		((version) & 0x0000007f)

Extracts patch level from version.

version :

the version number.

MI_SUCCESS

#define MI_SUCCESS	0

Indicates an operation is done successfully.


MI_FAILURE

#define MI_FAILURE	(-1)

Indicates an operation is failed.


SMFICTX

typedef struct smfi_str  SMFICTX;

Holds information for a milter session. SMFICTX is created for each milter session. SMFICTX is the most important object in libmilter API.


SMFICTX_PTR

typedef struct smfi_str *SMFICTX_PTR;

The pointer type of SMFICTX.


smfiDesc_str

typedef struct smfiDesc smfiDesc_str;

Holds information for the milter. smfiDesc_str is used by smfi_register().


smfiDesc_ptr

typedef struct smfiDesc	*smfiDesc_ptr;

The pointer type of smfiDesc_str.


sfsistat

typedef int sfsistat;

Indicates response status returned by callback.

Available response status is one of the followings:


bool

#      define bool int

The boolean type.


true

#      define true 1

The true value.


false

#      define false 0

The false value.


xxfi_connect ()

sfsistat            xxfi_connect                        (SMFICTX *context,
                                                         char *host_name,
                                                         _SOCK_ADDR *address);

This callback is called at the start of each milter session.

All available response statuses are the followings:

SMFIS_CONTINUE

Continues processing the current connection.

SMFIS_REJECT

Rejects the current connection.

SMFIS_ACCEPT

Accepts the current connection without further more processing.

SMFIS_TEMPFAIL

Rejects the current connection with a temporary failure. (i.e. 4xx status code in SMTP)

SMFIS_NOREPLY

Doesn't send a reply back to MTA. The milter must set SMFIP_NR_CONN flag to smfiDesc::xxfi_flags.

See also xxfi_connect on milter.org.

context :

the context for the current milter session.

host_name :

the host name of the SMTP client.

address :

the address of the SMTP client.

Returns :

response status.

xxfi_helo ()

sfsistat            xxfi_helo                           (SMFICTX *context,
                                                         char *fqdn);

This callback is called on SMTP's "HELO"/"EHLO" command.

All available response statuses are the followings:

SMFIS_CONTINUE

Continues processing the current connection.

SMFIS_REJECT

Rejects the current connection.

SMFIS_ACCEPT

Accepts the current connection without further more processing.

SMFIS_TEMPFAIL

Rejects the current connection with a temporary failure. (i.e. 4xx status code in SMTP)

SMFIS_NOREPLY

Doesn't send a reply back to MTA. The milter must set SMFIP_NR_HELO flag to smfiDesc::xxfi_flags.

See also xxfi_helo on milter.org.

context :

the context for the current milter session.

fqdn :

the FQDN in SMTP's "HELO"/"EHLO" command.

Returns :

response status.

xxfi_envfrom ()

sfsistat            xxfi_envfrom                        (SMFICTX *context,
                                                         char **arguments);

This callback is called on SMTP's "MAIL FROM" command.

All available response statuses are the followings:

SMFIS_CONTINUE

Continues processing the current message.

SMFIS_REJECT

Rejects the current envelope from address and message. A new envelope from may be specified.

SMFIS_DISCARD

Accepts the current message and discards it silently.

SMFIS_ACCEPT

Accepts the current message without further more processing.

SMFIS_TEMPFAIL

Rejects the current envelope from address and message with temporary failure. (i.e. 4xx status code in SMTP) A new envelope from address may be specified.

SMFIS_NOREPLY

Doesn't send a reply back to MTA. The milter must set SMFIP_NR_MAIL flag to smfiDesc::xxfi_flags.

See also xxfi_envfrom on milter.org.

context :

the context for the current milter session.

arguments :

the SMTP's "MAIL FROM" command arguments. The first element is sender address. NULL-terminated.

Returns :

response status.

xxfi_envrcpt ()

sfsistat            xxfi_envrcpt                        (SMFICTX *context,
                                                         char **arguments);

This callback is called on SMTP's "RCPT TO" command.

All available response statuses are the followings:

SMFIS_CONTINUE

Continues processing the current message.

SMFIS_REJECT

Rejects the current envelope recipient address. Processing the current messages is continued.

SMFIS_DISCARD

Accepts the current message and discards it silently.

SMFIS_ACCEPT

Accepts the current envelope recipient.

SMFIS_TEMPFAIL

Rejects the current envelope recipient address with temporary failure. (i.e. 4xx status code in SMTP) Processing the current message is continued.

SMFIS_NOREPLY

Doesn't send a reply back to MTA. The milter must set SMFIP_NR_RCPT flag to smfiDesc::xxfi_flags.

See also xxfi_envrcpt on milter.org.

context :

the context for the current milter session.

arguments :

the SMTP's "RCPT TO" command arguments. The first element is recipient address. NULL-terminated.

Returns :

response status.

xxfi_header ()

sfsistat            xxfi_header                         (SMFICTX *context,
                                                         char *name,
                                                         char *value);

This callback is called on each header. If SMFIP_HDR_LEADSPC flag is set to smfiDesc::xxfi_flags, value have spaces after header name and value separator ":".

Example:

From: from <from@example.com>
To: recipient <recipient@example.com>
Subject:a subject

With SMFIP_HDR_LEADSPC:

"From", " from <from@example.com>"
"To", " recipient <recipient@example.com>"
"Subject", "a subject"

Without SMFIP_HDR_LEADSPC:

"From", "from <from@example.com>"
"To", "recipient <recipient@example.com>"
"Subject", "a subject"

All available response statuses are the followings:

SMFIS_CONTINUE

Continues processing the current message.

SMFIS_REJECT

Rejects the current message.

SMFIS_DISCARD

Accepts the current message and discards it silently.

SMFIS_ACCEPT

Accepts the current message without further more processing.

SMFIS_TEMPFAIL

Rejects the current message with temporary failure. (i.e. 4xx status code in SMTP)

SMFIS_NOREPLY

Doesn't send a reply back to MTA. The milter must set SMFIP_NR_HDR flag to smfiDesc::xxfi_flags.

See also xxfi_header on milter.org.

context :

the context for the current milter session.

name :

the header name.

value :

the header value. value may include folded white space.

Returns :

response status.

xxfi_eoh ()

sfsistat            xxfi_eoh                            (SMFICTX *context);

This callback is called on all headers are processed.

All available response statuses are the followings:

SMFIS_CONTINUE

Continues processing the current message.

SMFIS_REJECT

Rejects the current message.

SMFIS_DISCARD

Accepts the current message and discards it silently.

SMFIS_ACCEPT

Accepts the current message without further more processing.

SMFIS_TEMPFAIL

Rejects the current message with temporary failure. (i.e. 4xx status code in SMTP)

SMFIS_NOREPLY

Doesn't send a reply back to MTA. The milter must set SMFIP_NR_EOH flag to smfiDesc::xxfi_flags.

See also xxfi_eof on milter.org.

context :

the context for the current milter session.

Returns :

response status.

xxfi_body ()

sfsistat            xxfi_body                           (SMFICTX *context,
                                                         unsigned char *data,
                                                         size_t data_size);

This callback is called on body data is received. This callback is called zero or more times between xxfi_eoh() and xxfi_eom().

All available response statuses are the followings:

SMFIS_CONTINUE

Continues processing the current message.

SMFIS_REJECT

Rejects the current message.

SMFIS_DISCARD

Accepts the current message and discards it silently.

SMFIS_ACCEPT

Accepts the current message without further more processing.

SMFIS_TEMPFAIL

Rejects the current message with temporary failure. (i.e. 4xx status code in SMTP)

SMFIS_SKIP

Skips further body processing. xxfi_eom() is called.

SMFIS_NOREPLY

Doesn't send a reply back to MTA. The milter must set SMFIP_NR_BODY flag to smfiDesc::xxfi_flags.

See also xxfi_body on milter.org.

context :

the context for the current milter session.

data :

the body chunk.

data_size :

the size of data.

Returns :

response status.

xxfi_eom ()

sfsistat            xxfi_eom                            (SMFICTX *context);

This callback is called after all xxfi_body() are called. All message modifications can be done only in this callback. The modifications can be done with smfi_addheader(), smfi_chgfrom() and so on.

All available response statuses are the followings:

SMFIS_CONTINUE

Continues processing the current message.

SMFIS_DISCARD

Accepts the current message and discards it silently.

SMFIS_ACCEPT

Accepts the current message without further more processing.

SMFIS_TEMPFAIL

Rejects the current message with temporary failure. (i.e. 4xx status code in SMTP)

See also xxfi_eom on milter.org.

context :

the context for the current milter session.

Returns :

response status.

xxfi_abort ()

sfsistat            xxfi_abort                          (SMFICTX *context);

This callback may be called at any time between xxfi_envfrom() and xxfi_eom(). This callback is only called if the milter causes an internal error and the message processing isn't completed. For example, if the milter has already returned SMFIS_ACCEPT, SMFIS_REJECT, SMFIS_DISCARD and SMFIS_TEMPFAIL, this callback will not be called.

If the milter has any resources allocated for the message between xxfi_envfrom() and xxfi_eom(), should be freed in this callback. But any resources allocated for the connection should not be freed in this callback. It should be freed in xxfi_close().

All available response statuses are the followings:

SMFIS_CONTINUE

Continues processing the current message.

SMFIS_DISCARD

Accepts the current message and discards it silently.

SMFIS_ACCEPT

Accepts the current message without further more processing.

SMFIS_TEMPFAIL

Rejects the current message with temporary failure. (i.e. 4xx status code in SMTP)

See also xxfi_abort on milter.org.

context :

the context for the current milter session.

Returns :

response status.

xxfi_close ()

sfsistat            xxfi_close                          (SMFICTX *context);

This callback is called at the end of each miler session. If the milter has any resources allocated for the session free, should be freed in this callback.

All response statuses are ignored. Use SMFIS_CONTINUE.

See also xxfi_close on milter.org.

context :

the context for the current milter session.

Returns :

response status.

xxfi_unknown ()

sfsistat            xxfi_unknown                        (SMFICTX *context,
                                                         const char *command);

This callback is called on unknown or unimplemented SMTP command is sent.

All available response statuses are the followings:

SMFIS_REJECT

Rejects the current message.

SMFIS_TEMPFAIL

Rejects the current message with temporary failure. (i.e. 4xx status code in SMTP)

SMFIS_NOREPLY

Doesn't send a reply back to MTA. The milter must set SMFIP_NR_UNKN flag to smfiDesc::xxfi_flags.

Note that the unknown or unimplemented SMTP command will always be rejected by MTA.

See also xxfi_unknown on milter.org.

context :

the context for the current milter session.

command :

the unknown SMTP command.

Returns :

response status.

xxfi_data ()

sfsistat            xxfi_data                           (SMFICTX *context);

This callback is called on SMTP's "DATA" command.

All available response statuses are the followings:

SMFIS_CONTINUE

Continues processing the current message.

SMFIS_REJECT

Rejects the current message.

SMFIS_DISCARD

Accepts the current message and discards it silently.

SMFIS_ACCEPT

Accepts the current envelope recipient.

SMFIS_TEMPFAIL

Rejects the current message with temporary failure. (i.e. 4xx status code in SMTP)

SMFIS_NOREPLY

Doesn't send a reply back to MTA. The milter must set SMFIP_NR_DATA flag to smfiDesc::xxfi_flags.

See also xxfi_data on milter.org.

context :

the context for the current milter session.

Returns :

response status.

xxfi_negotiate ()

sfsistat            xxfi_negotiate                      (SMFICTX *context,
                                                         unsigned long  actions,
                                                         unsigned long  steps,
                                                         unsigned long  unused0,
                                                         unsigned long  unused1,
                                                         unsigned long *actions_output,
                                                         unsigned long *steps_output,
                                                         unsigned long *unused0_output,
                                                         unsigned long *unused1_output);

This callback is called on negotiate request from MTA. If you want to change received actions and steps from MTA, you set actions_output and steps_output and returns SMFIS_CONTINUE. If you don't need to change actions and steps, you can just return SMFIS_ALL_OPTS.

All available response statuses are the followings:

SMFIS_ALL_OPTS

Enables all available actions and steps.

SMFIS_REJECT

Rejects the current session.

SMFIS_CONTINUE

Continues processing the current session with actions_output and steps_output.

See also xxfi_negotiate on milter.org.

context :

the context for the current milter session.

actions :

the actions received from MTA.

steps :

the milter protocol steps offered from MTA.

unused0 :

unused.

unused1 :

unused.

actions_output :

the actions requested to MTA.

steps_output :

the milter protocol steps requested to MTA.

unused0_output :

unused.

unused1_output :

unused.

Returns :

response status.

smfi_opensocket ()

int                 smfi_opensocket                     (bool remove_socket);

Creates the socket that is used to connect from MTA.

Normally, smfi_opensocket() isn't needed to call explicitly. The socket is created in smfi_main() implicitly.

Here are the fail conditions:

See also smfi_opensocket on milter.org.

remove_socket :

Whether or not trying to remove existing UNIX domain socket before creating a new socket.

Returns :

MI_SUCCESS if success, MI_FAILURE otherwise.

smfi_register ()

int                 smfi_register                       (struct smfiDesc description);

Registers the milter implementation as callbacks.

Here are the fail conditions:

  • incompatible xxfi_version.

  • illegal xxfi_flags value.

See also smfi_register on milter.org.

description :

The milter description.

Returns :

MI_SUCCESS if success, MI_FAILURE otherwise.

smfi_main ()

int                 smfi_main                           (void);

Enters event loop. The milter should be initialized with smfi_register(), smfi_setconn() and so on before smfi_main() is called.

Here are the fail conditions:

  • failed to create the socket.

See also smfi_main on milter.org.

Returns :

MI_SUCCESS if success, MI_FAILURE otherwise.

smfi_setbacklog ()

int                 smfi_setbacklog                     (int backlog);

Sets the milters' backlog value that is used for listen(2).

Here are the fail conditions:

  • backlog &lt;= 0.

See also smfi_setbacklog on milter.org.

backlog :

The maximum length of the pending connections queue.

Returns :

MI_SUCCESS if success, MI_FAILURE otherwise.

smfi_setdbg ()

int                 smfi_setdbg                         (int level);

Sets the log level. If level is 0, turns off any log message. The greater value is specified, more log messages are output.

See also smfi_setdbg on milter.org.

level :

The log level.

Returns :

always MI_SUCCESS.

smfi_settimeout ()

int                 smfi_settimeout                     (int timeout);

Sets the I/O timeout value in seconds. The default value is 7210 seconds. timeout == 0 means no wait, not "wait forever".

See also smfi_settimeout on milter.org.

timeout :

The timeout value in seconds.

Returns :

always MI_SUCCESS.

smfi_setconn ()

int                 smfi_setconn                        (char *connection_spec);

Sets the connection spec.

connection_spec format is one of them:

  • "unix:/PATH/TO/SOCKET": UNIX domain socket.

  • "inet:PORT", "inet:PORT@HOST_NAME" or "inet:PORT@IP_ADDRESS": IPv4.

  • "inet6:PORT", "inet6:PORT@HOST_NAME" or "inet6:PORT@IP_ADDRESS": IPv6.

Here are the fail conditions:

  • invalid format.

  • connection_spec is NULL.

See also smfi_setconn on milter.org.

connection_spec :

The connection spec for communicating MTA.

Returns :

MI_SUCCESS if success, MI_FAILURE otherwise.

smfi_stop ()

int                 smfi_stop                           (void);

Stops the milter. No more connections are accepted but processing connections are continued until they are finished.

See also smfi_stop on milter.org.

Returns :

always MI_SUCCESS.

smfi_version ()

int                 smfi_version                        (unsigned int *major,
                                                         unsigned int *minor,
                                                         unsigned int *patch_level);

Gets the libmilter version. The version is for using libmilter not built libmilter.

See also smfi_version on milter.org.

major :

return location for major version.

minor :

return location for minor version.

patch_level :

return location for patch level.

Returns :

always MI_SUCCESS.

SMFIF_ADDHDRS

#define SMFIF_ADDHDRS     0x00000001L

The milter may call smfi_addheader().

See also smfiDesc, xxfi_negotiate() and smfi_register on milter.org.


SMFIF_CHGBODY

#define SMFIF_CHGBODY     0x00000002L

The milter may call smfi_chgbody().

See also smfiDesc, xxfi_negotiate() and smfi_register on milter.org.


SMFIF_MODBODY

#define SMFIF_MODBODY     SMFIF_CHGBODY

Same as SMFIF_CHGBODY.


SMFIF_ADDRCPT

#define SMFIF_ADDRCPT     0x00000004L

The milter may call smfi_addrcpt().

See also smfiDesc, xxfi_negotiate() and smfi_register on milter.org.


SMFIF_DELRCPT

#define SMFIF_DELRCPT     0x00000008L

The milter may call smfi_delrcpt().

See also smfiDesc, xxfi_negotiate() and smfi_register on milter.org.


SMFIF_CHGHDRS

#define SMFIF_CHGHDRS     0x00000010L

The milter may call smfi_chgheader().

See also smfiDesc, xxfi_negotiate() and smfi_register on milter.org.


SMFIF_QUARANTINE

#define SMFIF_QUARANTINE  0x00000020L

The milter may call smfi_quarantine().

See also smfiDesc, xxfi_negotiate() and smfi_register on milter.org.


SMFIF_CHGFROM

#define SMFIF_CHGFROM     0x00000040L

The milter may call smfi_chgfrom().

See also smfiDesc, xxfi_negotiate() and smfi_register on milter.org.


SMFIF_ADDRCPT_PAR

#define SMFIF_ADDRCPT_PAR 0x00000080L

The milter may call smfi_addrcpt_par().

See also smfiDesc, xxfi_negotiate() and smfi_register on milter.org.


SMFIF_SETSYMLIST

#define SMFIF_SETSYMLIST  0x00000100L

The milter may call smfi_setsymlist().

See also smfiDesc, xxfi_negotiate() and smfi_register on milter.org.


SMFIS_CONTINUE

#define SMFIS_CONTINUE    0

Continues the current process.

See each callback (xxfi_connect(), xxfi_helo() and so on) and callback return status description on milter.org.


SMFIS_REJECT

#define SMFIS_REJECT      1

Rejects the current processing target.

See each callback (xxfi_connect(), xxfi_helo() and so on) and callback return status description on milter.org.


SMFIS_DISCARD

#define SMFIS_DISCARD     2

Accepts the current processing target and discards it silently.

See each callback (xxfi_envfrom(), xxfi_envrcpt() and so on) and callback return status description on milter.org.


SMFIS_ACCEPT

#define SMFIS_ACCEPT      3

Accepts the current processing target.

See each callback (xxfi_connect(), xxfi_helo() and so on) and callback return status description on milter.org.


SMFIS_TEMPFAIL

#define SMFIS_TEMPFAIL    4

Replies a temporary failure status for the current processing target.

See each callback (xxfi_connect(), xxfi_helo() and so on) and callback return status description on milter.org.


SMFIS_NOREPLY

#define SMFIS_NOREPLY     7

Doesn't reply to the MTA.

See each callback (xxfi_connect(), xxfi_helo() and so on) and callback return status description on milter.org.


SMFIS_SKIP

#define SMFIS_SKIP        8

Skips the rest body chunks. This can be used only in xxfi_body().

See also callback return status description on milter.org.


SMFIS_ALL_OPTS

#define SMFIS_ALL_OPTS    10

Uses the all negotiate options received from the MTA. This can be used only in xxfi_negotiate().


SMFIM_CONNECT

#define SMFIM_CONNECT	  0

Indicates the protocol stage for xxfi_connect().

See smfi_setsymlist().


SMFIM_HELO

#define SMFIM_HELO	  1

Indicates the protocol stage for xxfi_helo().

See smfi_setsymlist().


SMFIM_ENVFROM

#define SMFIM_ENVFROM	  2

Indicates the protocol stage for xxfi_envfrom().

See smfi_setsymlist().


SMFIM_ENVRCPT

#define SMFIM_ENVRCPT	  3

Indicates the protocol stage for xxfi_envrcpt().

See smfi_setsymlist().


SMFIM_DATA

#define SMFIM_DATA	  4

Indicates the protocol stage for xxfi_data().

See smfi_setsymlist().


SMFIM_EOM

#define SMFIM_EOM	  5

Indicates the protocol stage for xxfi_eom().

See smfi_setsymlist().


SMFIM_EOH

#define SMFIM_EOH	  6

Indicates the protocol stage for xxfi_eoh().

See smfi_setsymlist().


SMFIP_NOCONNECT

#define SMFIP_NOCONNECT       0x00000001L

Indicates that the MTA should not send information for xxfi_connect().

This flag can be got/set to steps_output of xxfi_negotiate().


SMFIP_NOHELO

#define SMFIP_NOHELO          0x00000002L

Indicates that the MTA should not send information for xxfi_helo().

This flag can be got/set to steps_output of xxfi_negotiate().


SMFIP_NOMAIL

#define SMFIP_NOMAIL          0x00000004L

Indicates that the MTA should not send information for xxfi_mail().

This flag can be got/set to steps_output of xxfi_negotiate().


SMFIP_NORCPT

#define SMFIP_NORCPT          0x00000008L

Indicates that the MTA should not send information for xxfi_rcpt().

This flag can be got/set to steps_output of xxfi_negotiate().


SMFIP_NOBODY

#define SMFIP_NOBODY          0x00000010L


SMFIP_NOHDRS

#define SMFIP_NOHDRS          0x00000020L

Indicates that the MTA should not send information for xxfi_header().

This flag can be got/set to steps_output of xxfi_negotiate().


SMFIP_NOEOH

#define SMFIP_NOEOH           0x00000040L

Indicates that the MTA should not send information for xxfi_eoh().

This flag can be got/set to steps_output of xxfi_negotiate().


SMFIP_NR_HDR

#define SMFIP_NR_HDR          0x00000080L

Indicates that the milter don't reply on xxfi_header().

This flag can be got/set to steps_output of xxfi_negotiate().


SMFIP_NOHREPL

#define SMFIP_NOHREPL         SMFIP_NR_HDR

Same as SMFIP_NR_HDR.


SMFIP_NOUNKNOWN

#define SMFIP_NOUNKNOWN       0x00000100L

Indicates that the MTA should not send information for xxfi_unknown().

This flag can be got/set to steps_output of xxfi_negotiate().


SMFIP_NODATA

#define SMFIP_NODATA          0x00000200L

Indicates that the MTA should not send information for xxfi_data().

This flag can be got/set to steps_output of xxfi_negotiate().


SMFIP_SKIP

#define SMFIP_SKIP            0x00000400L

Indicates that the MTA supports SMFIS_SKIP in xxfi_body().

This flag can be got/set to steps_output of xxfi_negotiate().


SMFIP_RCPT_REJ

#define SMFIP_RCPT_REJ        0x00000800L

Indicates that the MTA should send rejected envelope recipients and xxfi_envrcpt() is called for them.

This flag can be got/set to steps_output of xxfi_negotiate().


SMFIP_NR_CONN

#define SMFIP_NR_CONN         0x00001000L

Indicates that the milter don't reply on xxfi_connect().

This flag can be got/set to steps_output of xxfi_negotiate().


SMFIP_NR_HELO

#define SMFIP_NR_HELO         0x00002000L

Indicates that the milter don't reply on xxfi_helo().

This flag can be got/set to steps_output of xxfi_negotiate().


SMFIP_NR_MAIL

#define SMFIP_NR_MAIL         0x00004000L

Indicates that the milter don't reply on xxfi_envfrom().

This flag can be got/set to steps_output of xxfi_negotiate().


SMFIP_NR_RCPT

#define SMFIP_NR_RCPT         0x00008000L

Indicates that the milter don't reply on xxfi_envrcpt().

This flag can be got/set to steps_output of xxfi_negotiate().


SMFIP_NR_DATA

#define SMFIP_NR_DATA         0x00010000L

Indicates that the milter don't reply on xxfi_data().

This flag can be got/set to steps_output of xxfi_negotiate().


SMFIP_NR_UNKN

#define SMFIP_NR_UNKN         0x00020000L

Indicates that the milter don't reply on xxfi_unknown().

This flag can be got/set to steps_output of xxfi_negotiate().


SMFIP_NR_EOH

#define SMFIP_NR_EOH          0x00040000L

Indicates that the milter don't reply on xxfi_eoh().

This flag can be got/set to steps_output of xxfi_negotiate().


SMFIP_NR_BODY

#define SMFIP_NR_BODY         0x00080000L

Indicates that the milter don't reply on xxfi_body().

This flag can be got/set to steps_output of xxfi_negotiate().


SMFIP_HDR_LEADSPC

#define SMFIP_HDR_LEADSPC     0x00100000L

Indicates that xxfi_header() callback is received a header value including spaces after ':'. See xxfi_header() for examples.

This flag can be got/set to steps_output of xxfi_negotiate().


smfi_getsymval ()

char*               smfi_getsymval                      (SMFICTX *context,
                                                         char *name);

Gets a value of the macro named name in the current milter session context. smfi_getsymval() can be called in xxfi_XXX callbacks. (e.g. xxfi_connect(), xxfi_helo(), ...)

name should be enclosed in braces ("{" and "}") like "{if_name}" except name contains a character like "i".

See also smfi_getsymval on milter.org. Sendmail's default macros are also shown in the page.

context :

the context for the current milter session.

name :

the name of a macro.

Returns :

a value of the macro named name if it exists, NULL otherwise.

smfi_setreply ()

int                 smfi_setreply                       (SMFICTX *context,
                                                         char *return_code,
                                                         char *extended_code,
                                                         char *message);

Sets the error reply code. 4xx return_code is used on SMFIS_TEMPFAIL. 5xx return_code is used on SMFIS_REJECT.

Here are the fail conditions:

  • return_code is neither 4xx nor 5xx.

  • extended_code is neither 4.x.x nor 5.x.x.

See also smfi_setreply on milter.org.

context :

the context for the current milter session.

return_code :

the three-digit SMTP error reply code. (RFC 2821) Only 4xx and 5xx are accepted.

extended_code :

the extended reply code (RFC 1893/2034), or NULL. Only 4.x.x and 5.x.x are available.

message :

the text part of the SMTP reply, or NULL.

Returns :

MI_SUCCESS if success, MI_FAILURE otherwise.

smfi_setmlreply ()

int                 smfi_setmlreply                     (SMFICTX *context,
                                                         const char *return_code,
                                                         const char *extended_code,
                                                         ...);

Sets the error reply code. 4xx return_code is used on SMFIS_TEMPFAIL. 5xx return_code is used on SMFIS_REJECT.

Here are the fail conditions:

  • return_code is neither 4xx nor 5xx.

  • extended_code is neither 4.x.x nor 5.x.x.

See also smfi_setmlreply on milter.org.

context :

the context for the current milter session.

return_code :

the three-digit SMTP error reply code. (RFC 2821) Only 4xx and 5xx are accepted.

extended_code :

the extended reply code (RFC 1893/2034), or NULL. Only 4.x.x and 5.x.x are available.

... :

the single lines of text part of the SMTP reply, terminated by NULL.

Returns :

MI_SUCCESS if success, MI_FAILURE otherwise.

smfi_addheader ()

int                 smfi_addheader                      (SMFICTX *context,
                                                         char *name,
                                                         char *value);

Adds a header to the current message's header list. smfi_addheader() can be called in xxfi_eom().

Here are the fail conditions:

See also smfi_addheader on milter.org.

context :

the context for the current milter session.

name :

the header name.

value :

the header value.

Returns :

MI_SUCCESS if success, MI_FAILURE otherwise.

smfi_chgheader ()

int                 smfi_chgheader                      (SMFICTX *context,
                                                         char *name,
                                                         int index,
                                                         char *value);

Changes a header that is located at index in headers that all of them are named name. If value is NULL, the header is deleted. smfi_chgheader() can be called in xxfi_eom().

Here are the fail conditions:

See also smfi_chgheader on milter.org.

context :

the context for the current milter session.

name :

the header name.

index :

the index of headers that all of them are named name. (1-based)

value :

the header value. Use NULL to delete the target header.

Returns :

MI_SUCCESS if success, MI_FAILURE otherwise.

smfi_insheader ()

int                 smfi_insheader                      (SMFICTX *context,
                                                         int index,
                                                         char *name,
                                                         char *value);

Inserts a header to index in headers. smfi_insheader() can be called in xxfi_eom().

Here are the fail conditions:

See also smfi_insheader on milter.org.

context :

the context for the current milter session.

index :

the index of inserted header. 0 means that the header is prepended.

name :

the header name.

value :

the header value.

Returns :

MI_SUCCESS if success, MI_FAILURE otherwise.

smfi_chgfrom ()

int                 smfi_chgfrom                        (SMFICTX *context,
                                                         char *mail,
                                                         char *arguments);

Changes a sender address. smfi_chgfrom() can be called in xxfi_eom().

Here are the fail conditions:

See also smfi_chgfrom on milter.org.

context :

the context for the current milter session.

mail :

the new sender address.

arguments :

the extra arguments for ESMTP.

Returns :

MI_SUCCESS if success, MI_FAILURE otherwise.

smfi_addrcpt ()

int                 smfi_addrcpt                        (SMFICTX *context,
                                                         char *recipient);

Adds a recipient address. smfi_addrcpt() can be called in xxfi_eom().

Here are the fail conditions:

See also smfi_addrcpt on milter.org.

context :

the context for the current milter session.

recipient :

the new recipient address.

Returns :

MI_SUCCESS if success, MI_FAILURE otherwise.

smfi_addrcpt_par ()

int                 smfi_addrcpt_par                    (SMFICTX *context,
                                                         char *recipient,
                                                         char *arguments);

Adds a recipient address with extra ESMTP arguments. smfi_addrcpt_par() can be called in xxfi_eom().

Here are the fail conditions:

See also smfi_addrcpt_par on milter.org.

context :

the context for the current milter session.

recipient :

the recipient address.

arguments :

the extra arguments for ESMTP.

Returns :

MI_SUCCESS if success, MI_FAILURE otherwise.

smfi_delrcpt ()

int                 smfi_delrcpt                        (SMFICTX *context,
                                                         char *recipient);

Deletes a recipient address. smfi_delrcpt() can be called in xxfi_eom().

Here are the fail conditions:

See also smfi_delrcpt on milter.org.

context :

the context for the current milter session.

recipient :

the recipient address.

Returns :

MI_SUCCESS if success, MI_FAILURE otherwise.

smfi_progress ()

int                 smfi_progress                       (SMFICTX *context);

Keeps the current connection. smfi_progress() can be called in xxfi_eom().

Here are the fail conditions:

  • called in except xxfi_eom(). FIXME: not-implemented yet.

  • network error is occurred.

See also smfi_progress on milter.org.

context :

the context for the current milter session.

Returns :

MI_SUCCESS if success, MI_FAILURE otherwise.

smfi_replacebody ()

int                 smfi_replacebody                    (SMFICTX *context,
                                                         unsigned char *new_body,
                                                         int new_body_size);

Replaces the current body data with new_body. smfi_replacebody() can be called in xxfi_eom().

Here are the fail conditions:

See also smfi_replacebody on milter.org.

context :

the context for the current milter session.

new_body :

the new body data.

new_body_size :

the size of new_body.

Returns :

MI_SUCCESS if success, MI_FAILURE otherwise.

smfi_quarantine ()

int                 smfi_quarantine                     (SMFICTX *context,
                                                         char *reason);

Quarantines the current message with reason. smfi_quarantine() can be called in xxfi_eom().

Here are the fail conditions:

See also smfi_quarantine on milter.org.

context :

the context for the current milter session.

reason :

the quarantine reason.

Returns :

MI_SUCCESS if success, MI_FAILURE otherwise.

smfi_setpriv ()

int                 smfi_setpriv                        (SMFICTX *context,
                                                         void *data);

Sets the private data.

Here are the fail conditions:

  • context is invalid. FIXME: not-implemented yet.

See also smfi_setpriv on milter.org.

context :

the context for the current milter session.

data :

the private data.

Returns :

MI_SUCCESS if success, MI_FAILURE otherwise.

smfi_getpriv ()

void*               smfi_getpriv                        (SMFICTX *context);

Gets the private data.

Here are the fail conditions:

  • context is invalid. FIXME: not-implemented yet.

See also smfi_getpriv on milter.org.

context :

the context for the current milter session.

Returns :

the private data set by smfi_setpriv() or NULL.

smfi_setsymlist ()

int                 smfi_setsymlist                     (SMFICTX *context,
                                                         int state,
                                                         char *macros);

Sets the list of requested macros. smfi_setsymlist() can be called in xxfi_negotiate().

Here are the fail conditions:

  • state is not a valid value. FIXME: not-implemented yet.

  • macros is NULL or empty. FIXME: not-implemented yet.

  • the macro list for state has been set before. FIXME: not-implemented yet.

  • called in except xxfi_negotiate(). FIXME: not-implemented yet.

  • network error is occurred.

See also smfi_setsymlist on milter.org.

context :

the context for the current milter session.

state :

the state defined as SMFIM_XXX like SMFIM_CONNECT.

macros :

the space separated macro names like "{rcpt_mailer} {rcpt_host}".

Returns :

MI_SUCCESS if success, MI_FAILURE otherwise.