From owner-freebsd-questions@FreeBSD.ORG Fri Aug 31 14:22:05 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 1571D16A420 for ; Fri, 31 Aug 2007 14:22:05 +0000 (UTC) (envelope-from derek@computinginnovations.com) Received: from betty.computinginnovations.com (mail.computinginnovations.com [64.81.227.250]) by mx1.freebsd.org (Postfix) with ESMTP id 80BE813C465 for ; Fri, 31 Aug 2007 14:22:04 +0000 (UTC) (envelope-from derek@computinginnovations.com) Received: from p28.computinginnovations.com (dhcp-10-20-30-100.computinginnovations.com [10.20.30.100]) (authenticated bits=0) by betty.computinginnovations.com (8.13.8/8.12.11) with ESMTP id l7VELDXn001855; Fri, 31 Aug 2007 09:21:13 -0500 (CDT) Message-Id: <6.0.0.22.2.20070831090622.0267b180@mail.computinginnovations.com> X-Sender: derek@mail.computinginnovations.com X-Mailer: QUALCOMM Windows Eudora Version 6.0.0.22 Date: Fri, 31 Aug 2007 09:21:00 -0500 To: L Goodwin , Chuck Swiger From: Derek Ragona In-Reply-To: <169381.93008.qm@web58104.mail.re3.yahoo.com> References: <6.0.0.22.2.20070830194613.02635658@mail.computinginnovations.com> <169381.93008.qm@web58104.mail.re3.yahoo.com> Mime-Version: 1.0 X-ComputingInnovations-MailScanner-Information: Please contact the ISP for more information X-ComputingInnovations-MailScanner: Found to be clean X-ComputingInnovations-MailScanner-From: derek@computinginnovations.com X-Spam-Status: No Content-Type: text/plain; charset="us-ascii"; format=flowed X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-questions@freebsd.org 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: Fri, 31 Aug 2007 14:22:05 -0000 At 08:14 PM 8/30/2007, L Goodwin wrote: >--- Derek Ragona >wrote: > > > At 07:01 PM 8/30/2007, L Goodwin wrote: > > >Chuck, I'd prefer to have the script handle the > > >mailing so I can test the script (with email send) > > >manually, independent of cron. > > > > > >Still looking for specifics on setting this up and > > a > > >bourne shell script example that sends an email. > > >Thanks! > > > > > >--- Chuck Swiger wrote: > > > > > > > On Aug 30, 2007, at 3:12 PM, L Goodwin wrote: > > > > > I wrote a shell script that backs up the file > > > > server. > > > > > I would like to modify this script to email a > > > > > notification message to a public email > > address. > > > > > > > > Use cron, which will automatically email out the > > > > results of your > > > > script to any email address you like. > > > > > > > > > Seems like sendmail should do the job nicely, > > but > > > > I've never set it > > > > > up before. > > > > > > > > > > What specific steps (including > > network-specific) > > > > need > > > > > to be performed to get sendmail working for > > > > outgoing > > > > > mail only in a secure manner? > > > > > > > > Please see the fine Handbook: > > > > > > > > > > > > > > > >http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/mail.html > > > > > > > > Although, it is entirely reasonable to consider > > > > using Postfix instead. > > > > > > > > -- > > > > -Chuck > > > > > > > > > > > > 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. Mail is the local MTA to send via sendmail. All my servers run sendmail. >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? Some scripts may need to run as root. I have cron jobs I run as root, as root permissions are required. Other jobs I run as non-root users. Typically to run non-root jobs, create a new user group or use one that is existing and make a new user that is a member of that group. Typically a non-root task is analysis of webserver logs, since the webserver should run with non-root privileges. You can also use complex scripts where you combine root and non-root tasks using sudo for the root tasks. Like most tasks in a UNIX environment, there are many ways to do them. -Derek -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. MailScanner thanks transtec Computers for their support.