LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Cron and Mail (https://www.linuxquestions.org/questions/slackware-14/cron-and-mail-644419/)

Woodsman 05-23-2008 11:09 PM

Cron and Mail
 
I've been experimenting with cron and internal email. Nothing seems to work unless I start sendmail.

I suspect that cron cannot send mail unless a MTA is active. I'm guessing that cron uses whatever daemon occupies port 25. Is this correct?

Sendmail seems like heavy overhead for a single workstation not connected to a LAN. I've discovered that sendmail expects a fully qualified domain name, otherwise the program takes a very long time to start and fills my logs with cantankerous error messages to that effect. A FQDN is senseless with a single workstation. Lastly, I really do not want to spend any time learning anything about sendmail. I have more important items on my to do list. :)

Is there a more efficient solution that avoids running sendmail? All I want to do is allow cron to successfully send emails. Nothing more.

Thanks.

unSpawn 05-24-2008 06:33 AM

Quote:

Originally Posted by Woodsman (Post 3163056)
I've discovered that sendmail expects a fully qualified domain name (..) A FQDN is senseless with a single workstation.

Just make it the default "localhost.localdomain" entry?


Quote:

Originally Posted by Woodsman (Post 3163056)
Lastly, I really do not want to spend any time learning anything about sendmail.

Promoting the legendary "I do not need help, I can read" attitude that users of a certain distribution are renowned for, I see?

Woodsman 05-24-2008 04:33 PM

Quote:

Just make it the default "localhost.localdomain" entry?
Yes, that is what I did last night to avoid the delays in starting.

Quote:

Promoting the legendary "I do not need help, I can read" attitude that users of a certain distribution are renowned for, I see?
Perhaps I'm misreading your reply, but I haven't a clue to what you are referring, nor what distribution. :scratch: I ask plenty of questions here at LQ, which tends to negate any accusation about not needing help. I also try to reciprocate by maintaining an informational web site significantly focused on solving Slackware issues (read my sig).

I was only offering a statement that I have other things I want to focus rather than spend time learning sendmail. Learning sendmail is not high on my list. I was only looking for a MTA replacement to avoid using sendmail. As I stated in my original post, I only want to be able to receive mail from cron events. Seems like sendmail is significant overkill for such a nominal need.

unSpawn 05-25-2008 09:15 AM

Quote:

Originally Posted by Woodsman (Post 3163631)
Learning sendmail is not high on my list. (..) Seems like sendmail is significant overkill for such a nominal need.

I think that is debatable both in terms of performance and skills necessary to configure Sendmail to run. After all only having to fix the localhost line did it, right? :-]


Quote:

Originally Posted by Woodsman (Post 3163631)
Perhaps I'm misreading your reply

Yes, you did. Anyway. I'll describe my take on an alternative since I am not familiar with nullmailers (though probably a better alternative). This example should catch e-mail, hand off to the MDA and store in a simple mailbox uses Bash and Procmail, plus Netcat or (X)inetd. The listener will only listen on localhost and deliver to a user called "mailcatch":

Procmail recipe:
Code:

# /home/mailcatch/procmail.conf
# description: Rudimentary mail catcher.
PATH=/usr/local/bin:/usr/bin:/bin
VERBOSE=on
LOGABSTRACT=all
LOGFILE=/home/mailcatch/procmail.log
DEFAULT=/home/mailcatch/mbox

:0
*
$DEFAULT

Xinetd configuration file:
Code:

# /etc/xinetd.d/smtp
# default: on
# description: Rudimentary mail catcher.
service smtp
{
        disable = no
        socket_type    = stream
        protocol        = tcp
        port            = 25
        wait            = no
        user            = root
        server          = /usr/bin/procmail
        server_args    =  -t -f - -o -Y -m /home/mailcatch/procmail.conf
        log_on_failure  += USERID
        only_from      = 127.0.0.1/32
        max_load        = 1
}

Netcat alternative:
Code:

#!/bin/bash
#/etc/rc.d/rc.mailcatcher or something
# description: Rudimentary mail catcher.
mailcatch() { # Restarting listener
 /usr/bin/nc -n -4 -l 127.0.0.1 25 2>&1 \
 |/bin/grep -v "^Conn.*accepted$" \
 |/usr/bin/procmail -t -f - -o -Y -m /home/mailcatch/procmail.conf
}
case "$1" in
 start) mailcatch || mailcatch;;
 stop) /usr/bin/pkill -9 -f '/usr/bin/nc -n -4 -l 127.0.0.1 25' >/dev/null 2>&1;;
 restart) $0 stop; $0 start;;
esac
exit 0

To test copy a single message to a temporary file and remove any delivery or post-delivery flags the MTA, MDA or MUA added. Stop any MTA from running, then 'cat -v message | nc localhost 25', then check the $LOGFILE. I only tested with nc and mailbox format messages so YMMV(VM) as usual.


HTH

Woodsman 05-25-2008 12:01 PM

Thanks for the info.

As mentioned, I modified my hosts file to add localdomain and sendmail is running fine. Perhaps the overhead is not as much as I imagine and all of this is spilled milk. All is fine in Mudville. :)

My apologies for misunderstanding your previous response. I'm guessing you were being humorous or tongue-in-cheek, but I did not pause to consider that. :(

mRgOBLIN 05-25-2008 04:21 PM

And when did Slackware start using xinetd?


All times are GMT -5. The time now is 11:53 AM.