Gentoo Wiki


This article is part of the Tips & Tricks series.
Terminals / Shells Network X Window System Portage System Filesystems Kernel Other

This article is outdated. Please update this article with new information to match with the current portage tree and gentoo releases, and remove information about really old versions of software, then remove {{Update}} from this article's source.

Note: Starting with Portage 2.1.1, it is possible to specify /usr/sbin/sendmail in the PORTAGE_ELOG_MAILURI. This will make Portage use /usr/sbin/sendmail to send out the mail. Because of this, the TIP is now obsolete! See /etc/make.conf.example for further details.
PORTAGE_ELOG_MAILURI=" /usr/sbin/sendmail"

I didn't want to install a full fledged MTA like Postfix, Exim or qmail on my system but have setup ssmtp to send out my mails just fine. As I dislike duplicating configuration, I wanted to have Portage use ssmtp to send out mails generated by the PORTAGE_ELOG feature of Portage 2.1. Or, to put it more general, portage should send out mails using /usr/sbin/sendmail (or /usr/lib/sendmail) instead of SMTP.

To do this, I made sure that PORTAGE_ELOG_SYSTEM does NOT contain "mail" but at least "custom" (an additional "save" is fine as well) in /etc/make.conf. Further, the PORTAGE_ELOG_COMMAND needs to be set.

PORTAGE_ELOG_COMMAND="/usr/local/bin/ '\${PACKAGE}' '\${LOGFILE}'"

Here, needs to be replaced by the recipient address (think PORTAGE_ELOG_MAILURI) and needs to be replaced by the sender address (think PORTAGE_ELOG_MAILFROM). The backslahes (\) before the ${PACKAGE} and ${LOGFILE} are important - it must read \${PACKAGE} and \${LOGFILE}!

Next, the script referenced by PORTAGE_ELOG_COMMAND needs to be created.

Code: Script called by PORTAGE_ELOG_COMMAND "/usr/local/bin/"
#! /bin/sh

# Recipient address
# Sender address
# ${PACKAGE} - expands to the cpv entry of the processed
# package (see $PVR in ebuild(5))
# ${LOGFILE} - absolute path to the logfile - This will
# make up the e-mail body

# Name of the host from which this mail is sent
hostname=`hostname -f`
# Sender "full name"
from_fullname="Portage Log Message"

( printf "From: %s (%s)\nTo: %s\nSubject: [portage] ebuild log for %s on %s\n\n" \
        "$from" "$from_fullname" "$to" "$pvr" "$hostname"
  cat "$log_file"
) | sendmail -bm "$to"

if the e-mails have empty bodies, change the second last line to: "/${log_file#*/}"

Retrieved from ""

Last modified: Mon, 26 May 2008 09:04:00 +0000 Hits: 7,639