Mailfromd Manual (split by node):   Section:   Chapter:FastBack: Library   Up: Library   FastForward: Using MFL Mode   Contents: Table of ContentsIndex: Concept Index

5.31 Mail Sending Functions

The mail sending functions are new interfaces, introduced in version 3.1.

The underlying mechanism for sending mail, called mailer, is specified by --mailer command line option. This global setting can be overridden using the last optional argument to a particular function. In any case, the mailer is specified in the form of a URL.

Mailer URL begins with a protocol specification. Two protocol specifications are currently supported: ‘sendmail’ and ‘smtp’. The former means to use a sendmail-compatible program to send mails. Such a program must be able to read mail from its standard input and must support the following options:

-oi

Do not treat ‘.’ as message terminator.

-f addr

Use addr as the address of the sender.

-t

Get recipient addresses from the message.

These conditions are met by most existing MTA programs, such as exim or postfix (to say nothing of sendmail itself).

Following the protocol specification is the mailer location, which is separated from it with a colon. For the ‘sendmail’ protocol, the mailer location sets the full file name of the Sendmail-compatible MTA binary, for example:

sendmail:/usr/sbin/sendmail

A special form of a sendmail URL, consisting of protocol specification only (‘sendmail:’) is also allowed. It means “use the sendmail binary from the _PATH_SENDMAIL macro in your /usr/include/paths.h file”. This is the default mailer.

The ‘smtp’ protocol means to use an SMTP server directly. In this case the mailer location consists of two slashes, followed by the IP address or host name of the SMTP server, and, optionally, the port number. If the port number is present, it is separated from the rest of URL by a colon. For example:

smtp://remote.server.net
smtp://remote.server.net:24
Built-in Function: void send_mail (string msg [, string to, string from, string mailer])

Sends message msg to the email address to. The value of msg must be a valid RFC 2822 message, consisting of headers and body. Optional argument to can contain several email addresses. In this case the message will be sent to each recipient specified in to. If it is not specified, recipient addresses will be obtained from the message headers.

Other optional arguments are:

from

Sets the sender address. By default ‘<>’ is used.

mailer

The URL of the mailer to use

Sample usage:

    set message <<- EOT
          Subject: Test message
          To: Postmaster <postmaster@gnu.org.ua>
          From: Mailfromd <devnull@gnu.org.ua>
          X-Agent: %__package__ (%__version__)

          Dear postmaster,
          
          This is to notify you that our /etc/mailfromd.mf
          needs a revision.
          --
          Mailfromd filter administrator
    EOT
    send_mail(message, "postmaster@gnu.org.ua")
Built-in Function: void send_text (string text, string headers [, string to, string from, string mailer])

A more complex interface to mail sending functions.

Mandatory arguments:

text

Text of the message to be sent.

headers

Headers for the message.

Optional arguments:

to

Recipient email addresses.

from

Sender email address.

mailer

URL of the mailer to use.

The above example can be rewritten using send_text as follows:

    set headers << -EOT
          Subject: Test message
          To: Postmaster <postmaster@gnu.org.ua>
          From: Mailfromd <devnull@gnu.org.ua>
          X-Agent: %__package__ (%__version__)
    EOT
    set text <<- EOT
          Dear postmaster,
          
          This is to notify you that our /etc/mailfromd.mf
          needs a revision.
          --
          Mailfromd filter administrator
    EOT
    send_text(text, headers, "postmaster@gnu.org.ua")
Built-in Function: void send_message (number msg [string to, string from, string mailer])

Send the message identified by descriptor msg (see Message functions).

Optional arguments are:

to

Recipient email addresses.

from

Sender email address.

mailer

URL of the mailer to use.

Built-in Function: void send_dsn (string to, string sender, string rcpt, string text [, string headers, string from, string mailer])

This is an experimental interface which will change in the future versions. It sends a message disposition notification (RFC 2298, RFC 1894), of type ‘deleted’ to the email address to. Arguments are:

to

Recipient email address.

sender

Original sender email address.

rcpt

Original recipient email address.

text

Notification text.

Optional arguments:

headers

Message headers

from

Sender address.

mailer

URL of the mailer to use.

Built-in Function: void create_dsn (string sender, string rcpt, string text [, string headers, string from])

Creates DSN message and returns its descriptor. Arguments are:

sender

Original sender email address.

rcpt

Original recipient email address.

text

Notification text.

headers

Message headers

from

Sender address.

Mailfromd Manual (split by node):   Section:   Chapter:FastBack: Library   Up: Library   FastForward: Using MFL Mode   Contents: Table of ContentsIndex: Concept Index