LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 07-10-2006, 07:04 PM   #1
linuxhippy
Senior Member
 
Registered: Sep 2004
Location: Philadelphia, PA
Distribution: Xubuntu, Mythbuntu, Lubuntu, Picuntu, Mint 18.1, Debian Jessie
Posts: 1,207

Rep: Reputation: 47
crontab sendmail


I'd like to set a crontab to have my server logfile emailed to me. I set up sendmail for my user as root:

touch /var/spool/mail/huntz
chown huntz.users /var/spool/mail/huntz
chmod 660 /var/spool/mail/huntz

I tried this with no success:

cat /home/huntz/server/access_July06.log | sendmail huntz@verizon.net

I can set up crontabs...I just need to get sendmail working. What's wrong?
 
Old 07-10-2006, 07:13 PM   #2
vls
Member
 
Registered: Jan 2005
Location: The grassy knoll
Distribution: Slackware,Debian
Posts: 192

Rep: Reputation: 31
You can't call sendmail the way your doing. Use an email client, e.g. mail,nail, mutt
Example with nail:
Code:
nail -s "Logfile" -a /path/to/logfile you@somewhere.on.the.internet.
 
Old 07-10-2006, 07:26 PM   #3
linuxhippy
Senior Member
 
Registered: Sep 2004
Location: Philadelphia, PA
Distribution: Xubuntu, Mythbuntu, Lubuntu, Picuntu, Mint 18.1, Debian Jessie
Posts: 1,207

Original Poster
Rep: Reputation: 47
I have nail, but the nail line above wanted me to type in the email message. Do I need to configure nail first?
 
Old 07-10-2006, 07:46 PM   #4
vls
Member
 
Registered: Jan 2005
Location: The grassy knoll
Distribution: Slackware,Debian
Posts: 192

Rep: Reputation: 31
Quote:
Originally Posted by linuxhippy
I have nail, but the nail line above wanted me to type in the email message. Do I need to configure nail first?
No, I screwed up. For some reason I was thinking nail called from a script would just run.

Code:
nail -s "LogFile" youremail < /path/to/file
Sorry about that.
 
Old 07-11-2006, 05:05 PM   #5
linuxhippy
Senior Member
 
Registered: Sep 2004
Location: Philadelphia, PA
Distribution: Xubuntu, Mythbuntu, Lubuntu, Picuntu, Mint 18.1, Debian Jessie
Posts: 1,207

Original Poster
Rep: Reputation: 47
That command seemed to work but no email was sent???
 
Old 07-11-2006, 10:30 PM   #6
mdarby
Member
 
Registered: Nov 2004
Location: Columbus, Ohio
Distribution: Slackware-Current / Debian
Posts: 795

Rep: Reputation: 30
Just do
Code:
cat /var/log/maillog | mail you@somewhere.com
 
Old 07-12-2006, 07:17 PM   #7
linuxhippy
Senior Member
 
Registered: Sep 2004
Location: Philadelphia, PA
Distribution: Xubuntu, Mythbuntu, Lubuntu, Picuntu, Mint 18.1, Debian Jessie
Posts: 1,207

Original Poster
Rep: Reputation: 47
Mail didn't seem to do anything either. No error, it just left me at a prompt and no email arrived for me on the web.
 
Old 07-14-2006, 07:19 AM   #8
linuxhippy
Senior Member
 
Registered: Sep 2004
Location: Philadelphia, PA
Distribution: Xubuntu, Mythbuntu, Lubuntu, Picuntu, Mint 18.1, Debian Jessie
Posts: 1,207

Original Poster
Rep: Reputation: 47
I saw in my processes yesterday that sendmail was trying to send an email to my web based mail. Perhaps my iptables firewall is blocking mail transmission to the web? What port needs to be open?
 
Old 07-14-2006, 09:18 AM   #9
linuxhippy
Senior Member
 
Registered: Sep 2004
Location: Philadelphia, PA
Distribution: Xubuntu, Mythbuntu, Lubuntu, Picuntu, Mint 18.1, Debian Jessie
Posts: 1,207

Original Poster
Rep: Reputation: 47
looks like it's port 25-is it tcp with this rule in iptables:

ACCEPT tcp -- anywhere anywhere tcp dpt:25

Last edited by linuxhippy; 07-14-2006 at 09:21 AM.
 
Old 07-14-2006, 07:55 PM   #10
Wintceas
LQ Newbie
 
Registered: Sep 2004
Location: Brazil
Distribution: Slackware - Debian
Posts: 26

Rep: Reputation: 15
A nail/mail client sample script

Code:
printf "Report generated at: `date`\n" > /root/info.txt
printf "System name: `hostname`\n" >> /root/info.txt
printf "System version: `cat /proc/version`\n" >> /root/info.txt
printf "\n" >> /root/info.txt
printf "=============== DISK, MEMORY AND PROCESS STATUS ====================\n" >> /root/info.txt
printf "Uptime:\n" >> /root/info.txt
uptime >> /root/info.txt
printf "\n" >> /root/info.txt
printf "Who:\n" >> /root/info.txt
who >> /root/info.txt
printf "\n" >> /root/info.txt
printf "Last:\n" >> /root/info.txt
last | head >> /root/info.txt
printf "\n" >> /root/info.txt
printf "\n" >> /root/info.txt
printf "Free disk space:\n" >> /root/info.txt
df -h >>  /root/info.txt
printf "\n" >> /root/info.txt
printf "Memory Status:\n" >> /root/info.txt
free >> /root/info.txt
printf "\n" >> /root/info.txt
printf "Memory info:\n" >> /root/info.txt
cat /proc/meminfo >> /root/info.txt
printf "\n" >> /root/info.txt
printf "Swap info:\n" >> /root/info.txt
cat /proc/swaps >> /root/info.txt
printf "\n" >> /root/info.txt
printf "Processor info:\n" >> /root/info.txt
cat /proc/stat >> /root/info.txt
printf "\n" >> /root/info.txt
printf "Process list:\n" >> /root/info.txt
ps auxww | head -1 >> /root/info.txt
ps auxww | tail +2 | sort -r -k 5 >> /root/info.txt
printf "\n" >> /root/info.txt
printf "Resources usage:\n" >> /root/info.txt
top -n 1 -b | head -7 >> /root/info.txt
top -n 1 -b | tail +8 | sort -r -k 10 >> /root/info.txt
printf "\n" >> /root/info.txt
printf "\n" >> /root/info.txt
printf "========================= NETWORK STATUS ===========================\n" >> /root/info.txt
printf "\n" >> /root/info.txt
printf "External interface address:\n" >> /root/info.txt
/sbin/ifconfig ppp0 2> /dev/null | grep inet | cut -d : -f2 | cut -d \  -f1 >> /root/info.txt
printf "\n" >> /root/info.txt
printf "\n" >> /root/info.txt
printf "Iptables connection tracking:\n" >> /root/info.txt
cat /proc/net/ip_conntrack >> /root/info.txt
printf "\n" >> /root/info.txt
printf "Active connections:\n" >> /root/info.txt
netstat -tupn >> /root/info.txt
printf "\n" >> /root/info.txt
printf "Listening sockets:\n" >> /root/info.txt
netstat -tupan >> /root/info.txt
printf "\n" >> /root/info.txt
printf "Route info:\n" >> /root/info.txt
netstat -rn >> /root/info.txt
printf "\n" >> /root/info.txt
printf "Interfaces info:\n" >> /root/info.txt
netstat -i >> /root/info.txt
printf "\n" >> /root/info.txt
printf "Network statistics:\n" >> /root/info.txt
netstat -s >> /root/info.txt
printf "\n" >> /root/info.txt
printf "Wireless network status:\n" >> /root/info.txt
iwconfig >> /root/info.txt 2> /dev/null
printf "\n" >> /root/info.txt
printf "." >> /root/info.txt
printf "\n" >> /root/info.txt
cat /root/info.txt | nail -r root@localhost -n -v -s "Network status at `date`:" johndoe@gmail.com -c root@localhost
I had to put a dot "." in the last line of the message, because mail/nail in its absence would be waiting to more input. I put this little script inside /etc/cron.hourly and chmoded it to be an executable.

Last edited by Wintceas; 10-04-2006 at 08:15 PM.
 
Old 07-16-2006, 07:03 PM   #11
linuxhippy
Senior Member
 
Registered: Sep 2004
Location: Philadelphia, PA
Distribution: Xubuntu, Mythbuntu, Lubuntu, Picuntu, Mint 18.1, Debian Jessie
Posts: 1,207

Original Poster
Rep: Reputation: 47
ok, I ran that script with eth0 and different emails. I am running iptables and opened port 25 as a tcp connection with the rule above, then I rebooted and ran the above script. Still haven't gotten any emails. Here's the output after running the script:

220 LinuxHippy.example.org ESMTP Sendmail 8.13.7/8.13.4; Sun, 16 Jul 2006 19:40:02 -0400
>>> EHLO LinuxHippy.example.org
250-LinuxHippy.example.org Hello localhost [127.0.0.1], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-AUTH DIGEST-MD5 CRAM-MD5
250-DELIVERBY
250 HELP
>>> MAIL From:<huntz@LinuxHippy.example.org> SIZE=4406 AUTH=huntz@LinuxHippy.example.org
250 2.1.0 <huntz@LinuxHippy.example.org>... Sender ok
>>> RCPT To:<lxhippy@verizon.net>
>>> RCPT To:<kingskid@juno.com>
>>> DATA
250 2.1.5 <lxhippy@verizon.net>... Recipient ok
250 2.1.5 <kingskid@juno.com>... Recipient ok
354 Enter mail, end with "." on a line by itself
>>> .
250 2.0.0 k6GNe2Vs001190 Message accepted for delivery
lxhippy@verizon.net,kingskid_10@juno.com... Sent (k6GNe2Vs001190 Message accepted for delivery)
Closing connection to [127.0.0.1]
>>> QUIT
221 2.0.0 LinuxHippy.example.org closing connection


I got a locat email on my pc about this error for my verizon email account:
554 5.0.0 Service unavailable
<lxhippy@verizon.net>... Deferred: Connection timed out with relay.verizon.net.


Here's the info.txt file:

External interface address:
192.168.1.45
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 56472 192.168.1.45:8001 192.168.1.47:46645 ESTABLISHED 1158/perl
tcp 0 0 192.168.1.45:22 192.168.1.47:39401 ESTABLISHED 1132/sshd: huntz [p

Ip:
9071 total packets received
0 forwarded
0 incoming packets discarded
9060 incoming packets delivered
5076 requests sent out
Icmp:
10 ICMP messages received
1 input ICMP message failed.
ICMP input histogram:
destination unreachable: 10
0 ICMP messages sent
0 ICMP messages failed
ICMP output histogram:
Tcp:
8 active connections openings
4 passive connection openings
0 failed connection attempts
0 connection resets received
2 connections established
9043 segments received
5058 segments send out
31 segments retransmited
0 bad segments received.
10 resets sent
Udp:
18 packets received
0 packets to unknown port received.
0 packet receive errors
18 packets sent
TcpExt:
ArpFilter: 0
2 TCP sockets finished time wait in fast timer
5 delayed acks sent
1 delayed acks further delayed because of locked socket
Quick ack mode was activated 4 times
12 packets directly queued to recvmsg prequeue.
808 packets directly received from prequeue
327 packets header predicted
TCPPureAcks: 6840
TCPHPAcks: 1344
TCPRenoRecovery: 0
TCPSackRecovery: 0
TCPSACKReneging: 0
TCPFACKReorder: 0
TCPSACKReorder: 0
TCPRenoReorder: 0
TCPTSReorder: 0
TCPFullUndo: 0
TCPPartialUndo: 0
TCPDSACKUndo: 0
TCPLossUndo: 21
TCPLoss: 0
TCPLostRetransmit: 0
TCPRenoFailures: 0
TCPSackFailures: 0
TCPLossFailures: 0
TCPFastRetrans: 0
TCPForwardRetrans: 0
TCPSlowStartRetrans: 0
TCPTimeouts: 23
TCPRenoRecoveryFail: 0
TCPSackRecoveryFail: 0
TCPSchedulerFailed: 0
TCPRcvCollapsed: 0
TCPDSACKOldSent: 4
TCPDSACKOfoSent: 0
TCPDSACKRecv: 41
TCPDSACKOfoRecv: 0
TCPAbortOnSyn: 0
TCPAbortOnData: 0
TCPAbortOnClose: 0
TCPAbortOnMemory: 0
TCPAbortOnTimeout: 2
TCPAbortOnLinger: 0
TCPAbortFailed: 0
TCPMemoryPressures: 0

eth0 Link encap:Ethernet HWaddr 00:11:50:67C:BD
inet addr:192.168.1.45 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:9021 errors:0 dropped:0 overruns:0 frame:0
TX packets:5025 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:652904 (637.6 Kb) TX bytes:5668185 (5.4 Mb)

eth1 Link encap:Ethernet HWaddr 00:40:F4:4C:F0:80
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:3 Base address:0xb000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:54 errors:0 dropped:0 overruns:0 frame:0
TX packets:54 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:235814 (230.2 Kb) TX bytes:235814 (230.2 Kb)

eth0 IEEE 802.11g ESSID:"LinuxNeighborhood" Nickname:"LinuxHippy"
Mode:Managed Frequency:2.442 GHz Access Point: 00:E0:98:E1:94:21
Bit Rate=48 Mb/s Tx-Power:0 dBm
RTS thrff Fragment thrff
Encryption key:###########################
Power Managementff
Link Quality=7/94 Signal level=-69 dBm Noise level=-154 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:3240 Missed beacon:0.

Last edited by linuxhippy; 07-16-2006 at 07:05 PM.
 
Old 07-16-2006, 09:01 PM   #12
Wintceas
LQ Newbie
 
Registered: Sep 2004
Location: Brazil
Distribution: Slackware - Debian
Posts: 26

Rep: Reputation: 15
Quote:
Originally Posted by linuxhippy
ok, I ran that script with eth0 and different emails. I am running iptables and opened port 25 as a tcp connection with the rule above, then I rebooted and ran the above script. Still haven't gotten any emails. Here's the output after running the script:

...
I got a locat email on my pc about this error for my verizon email account:
554 5.0.0 Service unavailable
<lxhippy@verizon.net>... Deferred: Connection timed out with relay.verizon.net.

What /var/log/maillog reported in that date?

Still, if you want to bypass sendmail/postfix/qmail, you can add to your /etc/nail.rc the lines below:

set smtp="smtp.yahoo.com"
set smtp-auth-user="joe"
set smtp-auth-password="1234"

Don't forget to delete the "-n" in the last line of that script, as nail have to read nail.rc and use the remote smtp server, and not sendmail, that it tries to use by default. Also, the "-r" must contain a valid from address, that is, it must match the variable "smtp-auth-user" plus @ and the domain name of the server: "joe@yahoo.com". Unfortunately, I still can't figure out how to send messages using a ssl/tls enabled server, like smtp.gmail.com, though nail documentation is very informative on the subject.

Last edited by Wintceas; 07-16-2006 at 10:48 PM.
 
Old 07-17-2006, 05:50 PM   #13
linuxhippy
Senior Member
 
Registered: Sep 2004
Location: Philadelphia, PA
Distribution: Xubuntu, Mythbuntu, Lubuntu, Picuntu, Mint 18.1, Debian Jessie
Posts: 1,207

Original Poster
Rep: Reputation: 47
/var/log/maillog has this:

Jul 17 18:21:07 LinuxHippy sm-mta[1873]: k6D03uP4002862: to=<lxhippy@verizon.net>, ctladdr=<huntz@LinuxHippy.example.org> (1000/100), delay=4+22:17:10, xdelay=00:00:00, mailer=esmtp, pri=25288936, relay=relay.verizon.net., dsn=4.0.0, stat=Deferred: Connection timed out with relay.verizon.net.

I'll look at nail.rc
 
Old 07-24-2006, 03:02 PM   #14
Wintceas
LQ Newbie
 
Registered: Sep 2004
Location: Brazil
Distribution: Slackware - Debian
Posts: 26

Rep: Reputation: 15
Nail and Gmail/SSL SMTP SERVER

Quote:
Originally Posted by Wintceas
nfortunately, I still can't figure out how to send messages using a ssl/tls enabled server, like smtp.gmail.com, though nail documentation is very informative on the subject.
Here is the solution:

Open /etc/nail.rc and add the following settings:

Code:
ssl-no-default-ca
set from="username@gmail.com (My real name)"
set smtp="smtps://smtp.gmail.com:465"
set smtp-auth-user="username"
set smtp-auth-passwd="password"
A sample line to send a message:

Code:
cat /tmp/info.txt | nail -v -r username@gmail.com -s "test" admin@linuxquestions.org
Hope it helps.

Last edited by Wintceas; 12-28-2006 at 03:30 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Sendmail config questions + Sendmail not reflecting changes to access db wbuik Linux - Networking 2 03-26-2009 05:02 AM
sendmail is not working & on $prompt the cmd sendmail hangs Pavan mahoorker Linux - Software 1 04-04-2006 03:57 PM
system-wide crontab in /etc/crontab ner Linux - General 2 11-18-2003 12:35 PM
Sendmail/Crontab "Deferred" question Ionized Linux - Software 4 01-18-2003 02:07 AM
Sendmail - RunAsUser=sendmail:mail/What files to i have to change ForumKid Linux - Security 45 01-18-2002 11:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 03:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration