Commit c3c25fcd authored by Salvatore Bonaccorso's avatar Salvatore Bonaccorso

Imported Upstream version 1.2

José Fonseca <>
This diff is collapsed.
This diff is collapsed.
Basic Installation
These are generic installation instructions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, a file
`config.cache' that saves the results of its tests to speed up
reconfiguring, and a file `config.log' containing compiler output
(useful mainly for debugging `configure').
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If at some point `config.cache'
contains results you don't want to keep, you may remove or edit it.
The file `' is used to create `configure' by a program
called `autoconf'. You only need `' if you want to change
it or regenerate `configure' using a newer version of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes awhile. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
Compilers and Options
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. You can give `configure'
initial values for variables by setting them in the environment. Using
a Bourne-compatible shell, you can do that on the command line like
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
Or on systems that have the `env' program, you can do it like this:
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
Compiling For Multiple Architectures
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not supports the `VPATH'
variable, you have to compile the package for one architecture at a time
in the source code directory. After you have installed the package for
one architecture, use `make distclean' before reconfiguring for another
Installation Names
By default, `make install' will install the package's files in
`/usr/local/bin', `/usr/local/man', etc. You can specify an
installation prefix other than `/usr/local' by giving `configure' the
option `--prefix=PATH'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PATH', the package will use
PATH as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=PATH' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
There may be some features `configure' can not figure out
automatically, but needs to determine by the type of host the package
will run on. Usually `configure' can figure that out, but if it prints
a message saying it can not guess the host type, give it the
`--host=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name with three fields:
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the host type.
If you are building compiler tools for cross-compiling, you can also
use the `--target=TYPE' option to select the type of system they will
produce code for and the `--build=TYPE' option to select the type of
system on which you are compiling the package.
Sharing Defaults
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/' if it exists, then
`PREFIX/etc/' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Operation Controls
`configure' recognizes the following options to control how it
Use and save the results of the tests in FILE instead of
`./config.cache'. Set FILE to `/dev/null' to disable caching, for
debugging `configure'.
Print a summary of the options to `configure', and exit.
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
Print the version of Autoconf used to generate the `configure'
script, and exit.
`configure' also accepts some other, not widely useful, options.
AM_CFLAGS= -DSYSCONFDIR=\"@sysconfdir@\"
bin_PROGRAMS = esmtp
dist_man_MANS = esmtp.1 esmtprc.5
esmtp_SOURCES = \
lexer.l \
list.h \
local.c \
local.h \
main.c \
main.h \
message.c \
message.h \
parser.y \
rcfile.h \
rfc822.c \
rfc822.h \
smtp.c \
smtp.h \
BUILT_SOURCES = parser.h
sample.esmtprc \
$(mkinstalldirs) $(DESTDIR)$(sbindir) $(DESTDIR)$(libdir)
rm -f $(DESTDIR)$(sbindir)/sendmail
rm -f $(DESTDIR)$(libdir)/sendmail
rm -f $(DESTDIR)$(bindir)/mailq
rm -f $(DESTDIR)$(bindir)/newaliases
$(LN_S) $(bindir)/esmtp $(DESTDIR)$(sbindir)/sendmail
$(LN_S) $(bindir)/esmtp $(DESTDIR)$(libdir)/sendmail
$(LN_S) $(bindir)/esmtp $(DESTDIR)$(bindir)/mailq
$(LN_S) $(bindir)/esmtp $(DESTDIR)$(bindir)/newaliases
rm -f $(DESTDIR)$(man1dir)/sendmail.1
rm -f $(DESTDIR)$(man1dir)/mailq.1
rm -f $(DESTDIR)$(man1dir)/newaliases.1
$(LN_S) esmtp.1 $(DESTDIR)$(man1dir)/sendmail.1
$(LN_S) esmtp.1 $(DESTDIR)$(man1dir)/mailq.1
$(LN_S) esmtp.1 $(DESTDIR)$(man1dir)/newaliases.1
This diff is collapsed.
* Version 1.2 (2009-12-24):
* Make force_mda in the esmtprc to work with the -t option (based on patch
by Sourav K. Mandal)
* Version 1.1 (2009-12-16):
* Option to force local only MDA (Robert A.M. Diamond).
* Use locking in esmtp-wrapper (Phil Sutter).
* Update mutt option name in the user manual (Wu Fengguang).
* Version 1.0 (2008-10-09):
* Fix NTLM authentication (Nils Rennebarth).
* Option to disable Message-ID header (Phil Sutter).
* Version 0.6.0 (2007-09-03):
* Handle CR-LF newline endings when parsing the headers.
* Wrapper script for off-line mail delivery (Phil Sutter).
* Document how to get CA certificates.
* Corrections to the manpages (Reuben Thomas).
* Tips for adding missing Date: headers in messages for local delivery
(Bruce Schultz).
* Use a reasonable default for the reverse path when one is not
specified, instead of an empty one.
* Prevent segfault expanding %F in the MDA string when the reverse
path is not specified.
* Version 0.5.1 (2005-03-10):
* A 'postconnect' keyword to execute a command after closing a SMTP
* Do not attempt to authenticate if no username/password is given.
* Several configuration fixes/enhancements (SASAJIMA and Dirk Tilger).
* Enforce strict permissions on configuration file (Tiago Macambira).
* Allow to set helo-name. Allow to send out local mail as remote mail
by adding a qualifying domain name. Allow forcing envelope-from and Sender
headers. Drop possible admin-added sgid priveleges to be dropped after
reading the config. (Bernhard Link)
* Do not pass multiple address to the MDA quoted as a single argument
(Kusanagi Kouichi).
* Version 0.5.0 (2003-11-14):
* Fixed another bug which prevented to send mail when libesmtp had no
openssl support (Maurice Galland).
* Detailed documentation on how to use the StartTLS extension. More
verbosity on StartTLS error messages.
* New 'preconnect' keyword to execute a command prior to opening a SMTP
connection (Daniel Richard G.).
* Fixed a bug which prevented to send mail when libesmtp had no
openssl support (Tomas Kondor).
* New 'default' keyword for identities (Vitezslav Batrla).
* Version 0.4.1 (2003-07-14):
* Packaging fixes.
* Esmtprc man page.
* Fixed the MDA return status which wasn't being cheked.
* Fixed a bug the input buffering which when using the '-t' option and
piping the input caused the parsed headers to be lost.
* Version 0.4 (2003-07-12):
* Debian packaging.
* Fixes to compile on FreeBSD (Tim Hemel).
* Local delivery via a MDA.
* Extraction of the recipients from the headers ('-t' option).
* 8bit-MIME extension support ('-B' option).
* Further Delivery Status Notification support ('-R' and '-V' options).
* Version 0.3 (2003-03-10):
* Capability to generate log files.
* Better verbose output.
* Minor bug fixes and documentation enhancements.
* Multiple identities (Jerome).
* Version 0.2 (2002-10-31):
* Packaging corrections.
* Minor bug fixes and documentation enhancements.
* Use sendmail exit codes.
* Version 0.1 (2002-09-26):
* Initial release.
This diff is collapsed.
To Do
<<esmtp>> already fulfills all my needs, and I don't plan to spend much more
time on it besides bug fixing.
Here is a list of what can still be done:
* Write a comprehensive test suite.
* Alias expansion.
dnl @synopsis adl_FUNC_GETOPT_LONG
dnl Check for getopt_long support.
dnl This assume that the standard getopt.h file (from GNU libc) is
dnl available as lib/gnugetopt.h. If needed, this file will be linked
dnl as getopt.h, but we want to default to the system's getopt.h file.
dnl (See
dnl for an explanation about why using the system's getopt.h file is
dnl important.)
dnl @category InstalledPackages
dnl @author Alexandre Duret-Lutz <>
dnl @version 2003-10-29
dnl @license GPLWithACException
# clean out junk possibly left behind by a previous configuration
rm -f lib/getopt.h
# Check for getopt_long support
[# FreeBSD has a gnugetopt library for this
[# use the GNU replacement
dnl Same as above, but we don't need getopt_long -- just plain getopt --,
dnl and weren't including a GNU replacement .
# Check for getopt_long support
[# FreeBSD has a gnugetopt library for this
This diff is collapsed.
/* Generated from by autoheader. */
/* Define to 1 if you have the `geteuid' function. */
/* Define to 1 if you have the `getopt' function. */
/* Define to 1 if you have the <getopt.h> header file. */
/* Define to 1 if you have the `getuid' function. */
/* Define to 1 if you have the <inttypes.h> header file. */
/* Define to 1 if you have the <memory.h> header file. */
/* Define to 1 if you have the <stdint.h> header file. */
/* Define to 1 if you have the <stdlib.h> header file. */
/* Define to 1 if you have the <strings.h> header file. */
/* Define to 1 if you have the <string.h> header file. */
/* Define to 1 if you have the <sys/stat.h> header file. */
/* Define to 1 if you have the <sys/types.h> header file. */
/* Define to 1 if you have the <unistd.h> header file. */
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
/* Define to the full name of this package. */
/* Define to the full name and version of this package. */
/* Define to the one symbol short name of this package. */
/* Define to the home page for this package. */
/* Define to the version of this package. */
/* Define to 1 if you have the ANSI C header files. */
/* Version number of package */
#undef VERSION
/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
`char[]'. */
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
This diff is collapsed.
dnl Process this file with autoconf to produce a configure script.
AC_INIT(esmtp, 1.2)
AM_INIT_AUTOMAKE(1.11 dist-bzip2)
dnl getopt needs this
dnl Check for libESMTP
[use libesmtp library from (prefix) directory DIR]),
if test "$with_libesmtp" != "no" -a "$with_libesmtp" != "yes"
CPPFLAGS="$CPPFLAGS -I$with_libesmtp/include"
LDFLAGS="$LDFLAGS -L$with_libesmtp/lib"
AC_CHECK_HEADER(libesmtp.h, ,[AC_MSG_ERROR([libesmtp.h not found in $with_libesmtp])])
if libesmtp-config --version > /dev/null 2>&1
CFLAGS="$CFLAGS `libesmtp-config --cflags`"
LIBS="$LIBS `libesmtp-config --libs`"
AC_MSG_ERROR(libESMTP library not found)
AC_CHECK_FUNCS([getuid geteuid])
This diff is collapsed.
# Esmtp-wrapper adds shell based queueing support to esmtp.
# Copyright (C) 2007 by Phil Sutter <>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
__do_check_program() { # (path to program)
[ -x "$1" ] || { \
echo "required program '$1' not found, exiting"
exit 1
check_programs() { # ()
__do_check_program "$esmtp"
__do_check_program "$mktemp"
__do_check_program "$dotlockfile"
queue_mail() { # ($@)
local ret=0
mkdir -p "$qdir" || {
echo "unable to create queue dir $qdir" 2>&1
return 1
mdir="`$mktemp -d "$qdir/XXXXXXXX"`"
[ -d "$mdir" ] || {
echo "unable to create tempdir inside $qdir" 2>&1
return 1
touch "$mdir/lock"
echo "$@" >"$mdir/cmd" || ret=1
cat </dev/stdin >"$mdir/mail" || ret=1
[ $ret -eq 0 ] || {
echo "could not enqueue mail in dir $mdir" 2>&1
return 1
chmod 0600 $mdir/* || echo "warning setting secure permissions failed!" 2>&1
rm "$mdir/lock"
return 0
show_mail() { # ($mdir)
echo "mail in dir $1:"
printf '\t%s' "`grep ^From: "$1/mail"`"
printf '\t%s' "`grep ^To: "$1/mail"`"
[ -f "$1/lock" ] && printf '\t%s' "[LOCKED]"
printf '\t%s\n' "`grep ^Date: "$1/mail"`"
show_queue() { # ()
local i=0
local lockwarn=0
for dir in $qdir/*; do
[ ! -d "$dir" ] && continue
[ -f "$dir/lock" ] && lockwarn=1
show_mail $dir
let i++
echo "$i mails to deliver"
[ $lockwarn -eq 0 ] || { \
printf '\n%s\n' "Warning: locked mails in queue!"; \
printf '%s' "This means that either enqueueing is in "; \
printf '%s\n' "progress, or it failed for some reason."; \
send_mail() { # ($mdir)
$esmtp $(<"$1/cmd") <"$1/mail" && \
rm -rf "$1" || return 1
return $?
deliver_queue() { # ([background])
local undelivered=0
# when delivering in background, there is time to wait
# for a potential burst run (git-send-email, e.g.) or
# exiting of other delivery jobs.
if [[ "$1" = "background" ]]; then
sleep 5
if ! $dotlockfile -p -l "$deliver_lock"; then
return 1
for dir in $qdir/*; do
[ ! -d "$dir" ] && continue
[ -f "$dir/lock" ] && continue
send_mail "$dir"
undelivered=`expr $undelivered + $?`
$dotlockfile -u "$deliver_lock"
return $undelivered
ME=`basename "$0"`
check_programs # possible program exit point
case "$ME" in
queue_mail "$@" || return 1
deliver_queue "background" &
if [ x"$1" = x"-q" ]; then
exit 1
exit $?
.\" Based on ssmtp.1 and sendmail.8 man pages of the sSMTP and
.\" sendmail distributions respectively.
.\" Portions are
.\" Copyright (c) 1998-2002 Sendmail, Inc. and its suppliers.
.\" All rights reserved.
.\" Copyright (c) 1983, 1997 Eric P. Allman. All rights reserved.
.\" Copyright (c) 1988, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
libESMTP to Sendmail compatibility interface
\fBesmtp\fR [\fIflags\fR] [\fIaddress ...\fR]
\fBsendmail\fR [\fIflags\fR] [\fIaddress ...\fR]
\fBsendmail -bp\fR
\fBsendmail -bi\fR
\fBEsmtp\fR is a send-only \fBsendmail\fR emulator for machines which normally
retrieve their mail from a centralized mailhub using programs such as
\fBEsmtp\fR does not attempt to provide all the functionality of
\fBsendmail\fR: it is intended to be used by mail user agents as \fBmutt\fR.
Most \fBsendmail\fR options are irrelevant to \fBesmtp\fR . Those marked
``ignored'' or ``default'' have no effect on mail transfer. Those marked
``unsupported'' are fatal errors.
\fB\-Ac\fR (ignored)
Use even if the operation mode does not indicate an initial mail
\fB\-Am\fR (ignored)
Use even if the operation mode indicates an initial mail
\fB\-B\fR \fItype\fR
Set the body type to \fItype\fR. Current legal values are 7BIT or 8BITMIME.
\fB\-ba\fR (unsupported)
Go into ARPANET mode.
\fB\-bd\fR (unsupported)
Run as a daemon.
\fB\-bD\fR (unsupported)
Same as \fB\-bd\fR except runs in foreground.
\fB\-bh\fR (unsupported)