Next: Blacklisting Functions, Previous: Special test functions, Up: Library [Contents][Index]
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:
Do not treat ‘.’ as message terminator.
Use addr as the address of the sender.
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
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:
Sets the sender address. By default ‘<>’ is used.
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.mfl needs a revision. -- Mailfromd filter administrator EOT send_mail(message, "postmaster@gnu.org.ua")
A more complex interface to mail sending functions.
Mandatory arguments:
Text of the message to be sent.
Headers for the message.
Optional arguments:
Recipient email addresses.
Sender email address.
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.mfl needs a revision. -- Mailfromd filter administrator EOT send_text(text, headers, "postmaster@gnu.org.ua")
Send the message identified by descriptor msg (see Message functions).
Optional arguments are:
Recipient email addresses.
Sender email address.
URL of the mailer to use.
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:
Recipient email address.
Original sender email address.
Original recipient email address.
Notification text.
Optional arguments:
Message headers
Sender address.
URL of the mailer to use.
Creates DSN message and returns its descriptor. Arguments are:
Original sender email address.
Original recipient email address.
Notification text.
Message headers
Sender address.
Next: Blacklisting Functions, Previous: Special test functions, Up: Library [Contents][Index]