From owner-freebsd-questions@FreeBSD.ORG Sat Sep 1 00:06:10 2007 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 D343616A419 for ; Sat, 1 Sep 2007 00:06:10 +0000 (UTC) (envelope-from xrayv19@yahoo.com) Received: from web58110.mail.re3.yahoo.com (web58110.mail.re3.yahoo.com [68.142.236.133]) by mx1.freebsd.org (Postfix) with SMTP id 8047F13C428 for ; Sat, 1 Sep 2007 00:06:10 +0000 (UTC) (envelope-from xrayv19@yahoo.com) Received: (qmail 33041 invoked by uid 60001); 1 Sep 2007 00:06:09 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=1fBIypuIY0UDuPwfWVam8Eudz4q4Yjbqq9TG15q0OiIybvz63GojWT0sPabN4/GDvP42UUUMym6T2witZCAKzD2Y4X1t9/woxXzDsBpF7m6/CnFUVUXpNyoASMQayBlUt1mwwudENEr4kjeVFU7q73SghGq8kXGYoJcoAuA6Jeo=; X-YMail-OSG: Vfq0rW4VM1kzeGF3CeDsGXSoj8cQDm5pdiuiea1ymJ9W_6qAx7Yh64CH9u7J1VPlf9yzULyVD6LZetWh2qdD.LX4zbRpNTPqo03W Received: from [131.191.82.223] by web58110.mail.re3.yahoo.com via HTTP; Fri, 31 Aug 2007 17:06:09 PDT Date: Fri, 31 Aug 2007 17:06:09 -0700 (PDT) From: L Goodwin To: Ian Smith In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <674390.32697.qm@web58110.mail.re3.yahoo.com> Cc: freebsd-questions@freebsd.org, Derek Ragona Subject: Re: Configuring FreeBSD 6.2 to use sendmail for sending only 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, 01 Sep 2007 00:06:11 -0000 --- Ian Smith wrote: > On Thu, 30 Aug 2007 18:14:55 -0700 (PDT) L Goodwin > wrote: > > > --- Derek Ragona > wrote: > > [ slashing mercilessly ] > > > > >--- Chuck Swiger wrote: > [..] > > > > > Although, it is entirely reasonable to > consider > > > > > using Postfix instead. > > > > Here is a sample script that you can use as a > > > template: > > > ======================================================= > > > #!/bin/sh > > > > > > #define any commands you will use > > > MAILFILE=mymailfile > > > MAILFILE2=mymailfile2 > > > SENDTO=derek@computinginnovations.com > > > CCTO=derek@computinginnovations.com > > > MAIL=/usr/bin/mail > > > AWK=/usr/bin/awk > > > CAT=/bin/cat > > > TR=/usr/bin/tr > > > TEMPDIR=/tmp > > > > > > #make sure we have paths > > > export > PATH=$PATH:/usr/local/sbin:/usr/local/bin > > > > > > cd $TEMPDIR > > > $CAT /etc/passwd | $AWK -F : '{ print $5 }' > > > > $MAILFILE > > > $TR -cd "\012-\172" < $MAILFILE > $MAILFILE2 > > > $MAIL -s "My list of real user names subject" > > > $SENDTO -c $CCTO < $MAILFILE2 > > > ======================================================= > > > > Derek, your example brings up another question. > > > > Should I be calling "mail" or "sendmail", and > which > > mail or sendmail should I invoke if there is more > than > > one of either? Chuck's example calls sendmail in > a > > path that does not exist on my system (my > sendmail is > > in /usr/sbin/). I usually invoke whichever one is > > first in my path. > > Use whatever works for you, and it never hurts to be > specific :) > > > One more question. Is it ok to run the script > (and > > send the email) as user root, or should I create > a > > user account with more limited permissions -- if > so, > > what limits should I set? > > There are so many ways of doing this .. here's > another that we'd use to > mail out accounts to members monthly, from text > files generated by some > php and mysql magic on another box, by another guy. > > Note that this is enforced to be run by user 'subs' > (here uid 996), so > that's who these messages are 'From:'. A script run > from cron need not > be so paranoid about checking things .. this was > hand-run 'when ready'. > > #!/bin/sh > # sendacts 7Jan00 smithi .. mail out SubsBot > messages .. cleanup 2Oct02 > # each *.act file begins with To:, Cc:, X-mailer: > etc lines > > maildir="/home/subs/bills/$1" # preexisting dir as > parameter eg '2000-01' > mailrun="./command.txt" # perline format: > 'sendmail -t < userX.act 2>&1' > > if [ "`id -u`" != "996" ]; then > echo "$0 must be run as user subs .. 'su subs' > and retry .." > elif [ "$1" = "" ]; then > echo "usage: $0 directory" > elif [ ! -d $maildir ]; then > echo "$maildir does not exist .. mkdir first, > unpack zipfile there" > elif [ ! -w $maildir ]; then > echo "$maildir is not writeable .. an older > locked one, perhaps?" > else > cd $maildir > if [ ! -f $mailrun ]; then > echo "can't find ${maildir}/${mailrun} .. > zipfile not unpacked?" > elif [ -f ./mailout.done ]; then > echo "'rm ${maildir}/mailout.done' if you > wanna repeat mailout?" > else > umask 27 > echo "$0 sending mail:" ; cat $mailrun > . $mailrun > touch ./mailout.done ; echo "$0 done" > exit 0 > fi > fi > exit 1 > > with ./command.txt containing a line per recipient > such as: > > sendmail -t < user1.act 2>&1 > sendmail -t < user2.act 2>&1 > [..] > sendmail -t < userN.act 2>&1 > > and with the *.act files beginning such as: > > To: smithi@nimnet.asn.au > Subject: August 2006 Account for Ian Smith > Cc: subs@nimnet.asn.au > Reply-to: subs@nimnet.asn.au > X-Mailer: subsbot v0.9 beta 8.90 :) > > Hello Ian Smith, > [..] > > HTH, Ian > Thanks for sharing your example, Ian. They all help! ____________________________________________________________________________________ Got a little couch potato? Check out fun summer activities for kids. http://search.yahoo.com/search?fr=oni_on_mail&p=summer+activities+for+kids&cs=bz