Slackware This Forum is for the discussion of Slackware Linux.
Notices
Welcome to
LinuxQuestions.org , a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free.
Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please
contact us . If you need to reset your password,
click here .
10-03-2007, 08:54 PM
#1
LQ Newbie
Registered: Jul 2007
Location: ohio
Distribution: Slackware, FreeBSD
Posts: 26
Thanked: 0
Email Logs Slackware 12
[
Log in to
get rid of this advertisement]
I want to be able to email myself from a cron job.
I have this set up using ssmtp on my router but I would like my web server box to do something similar.
Tutorials that I have went though don't seem to get me anywhere.
ssmtp was nice since I could use a gmail account to send messages from.
10-04-2007, 01:11 AM
#2
Senior Member
Registered: Oct 2005
Location: Lithuania
Distribution: Hybrid
Posts: 2,220
Thanked: 7
Can you elaborate more about your problem?
10-04-2007, 02:00 AM
#3
LQ Newbie
Registered: Jul 2007
Location: ohio
Distribution: Slackware, FreeBSD
Posts: 26
Thanked: 0
Original Poster
i think i basically need a script that will email me httpd logs or logs from /var/log that i can cron to send them at a certain time each day
10-04-2007, 11:54 AM
#4
Slackware Contributor
Registered: Oct 2004
Location: Tuscaloosa, Alabama (USA)
Distribution: Slackware
Posts: 1,396
Thanked: 128
Look into using mailx(1)
10-06-2007, 11:34 AM
#5
LQ Newbie
Registered: Aug 2005
Location: Charleston, SC.
Posts: 16
Thanked: 0
Hi,
I'm the guy thoron posted this for...
I've gotton this far:
Using mailx to use smtp.gmail.com, since I can't send mail directly to the gmail account (invalid ip address, would have to relay through isp smtp...).
mailx -v -s Test -S smtp-use-starttls -S smtp-auth=login -S smtp=smtp.gmail.com:587 -S from=fromEmail@gmail.com -S smtp-auth-user=user@gmail.com -S smtp-auth-password="password"
toEmail@gmail.com
This results in:
Code:
Resolving host smtp.gmail.com . . . done.
Connecting to 64.233.185.111 . . . connected.
220 mx.google.com ESMTP g9sm5349298wra
>>> EHLO serverName.com
250-mx.google.com at your service, [68.58.162.123]
250-SIZE 28311552
250-8BITMIME
250-STARTTLS
250 ENHANCEDSTATUSCODES
>>> STARTTLS
220 2.0.0 Ready to start TLS
Error with certificate at depth: 0
issuer = /C=ZA/ST=Western Cape/L=Cape Town/O=Thawte Consulting cc/OU=Certification Services Division/CN=Thawte Premium Server CA/emailAddress=premium-server@thawte.com
subject = /C=US/ST=California/L=Mountain View/O=Google Inc/CN=smtp.gmail.com
err 20: unable to get local issuer certificate
Continue (y/n)? could not initiate SSL/TLS connection: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
"/home/pricejm/dead.letter" 11/315
. . . message not sent.
10-06-2007, 11:44 AM
#6
LQ Newbie
Registered: Aug 2005
Location: Charleston, SC.
Posts: 16
Thanked: 0
Ok I added "-S ssl-verify=ignore" and it went through.
Maybe I need to grab a cert and save it?
Now figuring that one out...
Last edited by pricejm; 10-06-2007 at 11:52 AM ..
10-06-2007, 01:33 PM
#7
LQ Newbie
Registered: Aug 2005
Location: Charleston, SC.
Posts: 16
Thanked: 0
This is what I concluded with:
Code:
#! /bin/sh
ACCESS_LOG=/var/log/httpd/access_log
ERROR_LOG=/var/log/httpd/error_log
SMTP=smtp.gmail.com:587
FROM_MAIL=fromMail@gmail.com
LOGIN=logIn@gmail.com
LOGIN_PASSWORD=password
TO_MAIL=toMail@gmail.com
#Email access log
SUBJECT='httpd Access Log'
cat $ACCESS_LOG | mailx $1 -s "$SUBJECT" -S ssl-verify=ignore -S smtp-use-starttls -S smtp-auth=login -S smtp="$SMTP" -S from="$FROM_MAIL" -S smtp-auth-user="$LOGIN" -S smtp-auth-password="$LOGIN_PASSWORD" $TO_MAIL
#Email error log
SUBJECT='httpd Error Log'
cat $ERROR_LOG | mailx $1 -s "$SUBJECT" -S ssl-verify=ignore -S smtp-use-starttls -S smtp-auth=login -S smtp="$SMTP" -S from="$FROM_MAIL" -S smtp-auth-user="$LOGIN" -S smtp-auth-password="$LOGIN_PASSWORD" $TO_MAIL
#Truncate logs
echo -n > $ACCESS_LOG
echo -n > $ERROR_LOG
Now I can just throw this script at cron and just check my email. I have another GMail account that is used to sends the messages, don't have to bother with the Sent mail and this clear text pword. I just put a filter that applies a label to the particular email in GMail. Makes storing logs pretty easy.
I'd rather not have to ignore the ssl failures but I'll save that for another day.
Thank you
thoron for starting this and
rworkman for pointing me to mailx.
Last edited by pricejm; 10-06-2007 at 03:37 PM ..
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
All times are GMT -5. The time now is 11:17 PM .
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know .
Latest Threads
LQ News
LQ Podcast
LQ Radio