From owner-freebsd-questions@FreeBSD.ORG Sat Oct 24 17:02:32 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 52CFD106568D for ; Sat, 24 Oct 2009 17:02:31 +0000 (UTC) (envelope-from m.seaman@infracaninophile.co.uk) Received: from smtp.infracaninophile.co.uk (gate6.infracaninophile.co.uk [IPv6:2001:8b0:151:1::1]) by mx1.freebsd.org (Postfix) with ESMTP id D94BA8FC42 for ; Sat, 24 Oct 2009 17:02:30 +0000 (UTC) Received: from happy-idiot-talk.infracaninophile.co.uk (localhost [IPv6:::1]) (authenticated bits=0) by smtp.infracaninophile.co.uk (8.14.3/8.14.3) with ESMTP id n9OH2OmX056404; Sat, 24 Oct 2009 18:02:25 +0100 (BST) (envelope-from m.seaman@infracaninophile.co.uk) X-DKIM: Sendmail DKIM Filter v2.8.3 smtp.infracaninophile.co.uk n9OH2OmX056404 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=infracaninophile.co.uk; s=200708; t=1256403745; bh=fNi2XUsF1PhP/Pr4cCzCN+Bs6BBr7UnIw6RnxBxv7og=; h=Message-ID:Date:From:MIME-Version:To:CC:Subject:References: In-Reply-To:Content-Type:Cc:Content-Type:Date:From:In-Reply-To: Message-ID:Mime-Version:References:To; z=Message-ID:=20<4AE33318.2040000@infracaninophile.co.uk>|Date:=20S at,=2024=20Oct=202009=2018:02:16=20+0100|From:=20Matthew=20Seaman= 20|Organization:=20Infracaninophi le|User-Agent:=20Thunderbird=202.0.0.23=20(X11/20090823)|MIME-Vers ion:=201.0|To:=20Paul=20Schmehl=20| CC:=20Kelly=20Martin=20,=20=0D=0A=20FreeBSD =20Questions=20|Subject:=20Re:=20ch anging=20cron's=20From:=20address=20in=20emails|References:=20<133 8880b0910240008h5d5e7846q8ccf184728d9e036@mail.gmail.com>=20<4AE2C 5F4.20109@infracaninophile.co.uk>=20|In-Reply-To:=20|X-E nigmail-Version:=200.95.6|Content-Type:=20multipart/signed=3B=20mi calg=3Dpgp-sha256=3B=0D=0A=20protocol=3D"application/pgp-signature "=3B=0D=0A=20boundary=3D"------------enig38A4C2AD9C859A51427CAEE2" ; b=uPxG3xP6xGvrDx1Wu6352e4HWRA/0fyq0Ds69PkW5utw0/S91u82JbYfqB2GJMNIX ljEHXP5e+qWhB7Wf+Db485JWxs1AKrTbAS5F2hRbWOYgAnGHNCTGqdHuWXKa2ssEvE Es5dCV+EfiENfQksKmlqKrLMoaF4xoWuY5T3LduU= X-Authentication-Warning: happy-idiot-talk.infracaninophile.co.uk: Host localhost [IPv6:::1] claimed to be happy-idiot-talk.infracaninophile.co.uk Message-ID: <4AE33318.2040000@infracaninophile.co.uk> Date: Sat, 24 Oct 2009 18:02:16 +0100 From: Matthew Seaman Organization: Infracaninophile User-Agent: Thunderbird 2.0.0.23 (X11/20090823) MIME-Version: 1.0 To: Paul Schmehl References: <1338880b0910240008h5d5e7846q8ccf184728d9e036@mail.gmail.com> <4AE2C5F4.20109@infracaninophile.co.uk> In-Reply-To: X-Enigmail-Version: 0.95.6 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig38A4C2AD9C859A51427CAEE2" X-Virus-Scanned: clamav-milter 0.95.2 at happy-idiot-talk.infracaninophile.co.uk X-Virus-Status: Clean X-Spam-Status: No, score=-3.0 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VERIFIED,NO_RELAYS autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on happy-idiot-talk.infracaninophile.co.uk Cc: Kelly Martin , FreeBSD Questions Subject: Re: changing cron's From: address in emails X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 24 Oct 2009 17:02:32 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig38A4C2AD9C859A51427CAEE2 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Paul Schmehl wrote: > --On Saturday, October 24, 2009 4:16 AM -0500 Matthew Seaman=20 > wrote: >=20 >> Kelly Martin wrote: >>> Greetings, here's a simple question for the FreeBSD gurus out there. = I >>> have several servers running cron scripts daily for me, and they all >>> send me e-mail with their output. Regardless of which server it is, >>> each of these e-mails have the From: address looking exactly the same= =2E >>> They all say they are from the "Cron Daemon". Fine, but I'd like to >>> know more clearly which server the cron output is from. >>> >>> How can I change the From: address of these emails to "Myserver Cron >>> Daemon" instead? I know cron runs as the user, so it's not immediatel= y >>> obvious to me how to change the From: field. Already the subject line= >>> says something like "Cron ..." but this doesn't stand= >>> out enough for my tired eyes. >> >> Hmmm... that's actually quite tricky. There's no facility within >> cron(8) for changing the address it sends /from/, and as the bit you >> want to change is technically a comment on the From: line, and not >> the actual sender address (the bit in the ) all the >> address rewriting-fu in sendmail won't really help. Besides, root@...= >> is listed as a member of the 'Exposed User' class: that is, addresses >> that should be exempt from address rewriting, so you'ld also have to >> modify that. >> >> Do you control the mail server where you read your e-mail? Can you us= e >> eg. procmail(1) as a delivery agent? You should be able to match e-ma= ils >> from Cron and rewrite headers, or deliver cron e-mails into per-machin= e >> mailboxes. Something like this: >> >> :0 h >> * From:.*Cron > $MATCH >> >> The other alternative is to re-write the cron scripts to send e-mail >> themselves, rather than relying on cron(8) to capture their stdout/std= err >> and e-mail it for you. Here's a handy shell programming trick that ca= n >> make that easier. Somewhere near the top of the script, you can add >> something like this: >> >> exec 2>&1 | /usr/sbin/sendmail -oi -t >> echo "From: Sender Name >> echo "To: >> echo "Subject: e-mail from cron job" >> echo "" >> >> Then everything you print out in the script will be captured as the bo= dy >> of the e-mail and sent to the specified recipient. You might get some= >> warnings about forgery in the mail headers if the userid the script ru= ns >> as is not the same as the 'From:' address. >> >=20 > Why not just echo `hostname` as the first line of every script? Isn't = > that what he really wants to know? >=20 > Or echo "This script came from `hostname`"? There is that, but I had assumed the idea was to be able to better distinguish the different e-mails /before/ opening them up in the MUA. Cheers, Matthew --=20 Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard Flat 3 PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate Kent, CT11 9PW --------------enig38A4C2AD9C859A51427CAEE2 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.13 (FreeBSD) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEAREIAAYFAkrjMyAACgkQ8Mjk52CukIxF6wCfZInb5Km+bJ8sivofK4Okr45F xc8An17YZ5CQvGx0VCBYHk4s9diYenS1 =rFGB -----END PGP SIGNATURE----- --------------enig38A4C2AD9C859A51427CAEE2--