Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Postfix / mail
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
El-Marty
n00b
n00b


Joined: 05 Feb 2007
Posts: 5

PostPosted: Sun Jun 17, 2007 4:17 pm    Post subject: Postfix / mail Reply with quote

Hello,

I'm using a gentoo server to monitor my networks.
What I'm trying to do is send a mail from a local user (nagios) to another local user (root, or something else.), and when I get mail, the mail shold be parsed though a script, and then be sent directly to my cell phone as an sms.
Now everyting seems ok, but I'm actually having problems recieving mail on my local account. should be the ONE thing that is pretty straight-forward on a linux box. haha.

I use postfix as a sendmail agent, and the following output is logged after sending a mail from martinn to root:

Jun 17 17:42:20 super postfix/pickup[30937]: 5EB36B80C9: uid=1001 from=<martinn>
Jun 17 17:42:20 super postfix/cleanup[30942]: 5EB36B80C9: message-id=<20070617154220.5EB36B80C9@localhost>
Jun 17 17:42:20 super postfix/qmgr[30938]: 5EB36B80C9: from=<martinn@localhost.xxxx.xx>, size=297, nrcpt=1 (queue active)
Jun 17 17:42:20 super postfix/local[30944]: 5EB36B80C9: to=<root@localhost.xxx.xx>, orig_to=<root@localhost>, relay=local, delay=0.14, delays=0.09/0.01/0/0.04, dsn=2.0.0, status=sent (delivered to maildir)
Jun 17 17:42:20 super postfix/qmgr[30938]: 5EB36B80C9: removed
Jun 17 17:46:50 super postfix/postfix-script: refreshing the Postfix mail system
Jun 17 17:46:50 super postfix/master[30936]: reload configuration /etc/postfix

seems ok then.
This is important parts of my etc/postfix/main.cf:

home_mailbox = Mailbox
mail_spool_directory = /var/spool/mail
home_mailbox = .maildir/
mynetworks_style = host
mydestination = $myhostname, localhost.$mydomain, localhost
inet_interfaces = $myhostname, localhost
myhostname = localhost
mydomain = xxxxx.xx

an ls of var/spool/mail:

ls -l /var/spool/mail
total 0
---------- 1 root root 0 Apr 12 15:29 admin
---------- 1 root root 0 Apr 12 12:07 apache
---------- 1 root root 0 Apr 11 16:19 cron
---------- 1 root root 0 Jun 17 14:58 mail2sms
---------- 1 root root 0 May 10 12:35 martinn
---------- 1 root root 0 Apr 12 13:24 mysql
---------- 1 root root 0 Apr 12 13:46 nagios
---------- 1 root root 0 Apr 12 12:10 ntp
---------- 1 root root 0 Jun 17 17:07 postfix
---------- 1 root root 0 Jun 6 16:23 rancid

Now, postfix seems to be working just fine, this is the root mail folder:

super new # pwd;ls -l
/root/.maildir/new
total 20
-rw------- 1 root root 390 Jun 17 17:18 1182093484.V6802I3f4a97M779307.super.xxxx.xx
-rw------- 1 root root 395 Jun 17 17:21 1182093668.V6802I3f4a9aM837321.super.xxxx.xx
-rw------- 1 root root 421 Jun 17 17:28 1182094126.V6802I3f4a9bM502869.super.xxxx.xx
-rw------- 1 root root 401 Jun 17 17:38 1182094732.V6802I3f4a9cM799604.super.xxxx.xx
-rw------- 1 root root 398 Jun 17 17:42 1182094940.V6802I3f4a9dM444544.super.xxxx.xx

Now, if we take a look at the newest mail here:

super new # cat *444544*
Return-Path: <martinn@localhost.xxxx.xx>
X-Original-To: root@localhost
Delivered-To: root@localhost.xxxxx.xx
Received: by localhost (Postfix, from userid 1001)
id 5EB36B80C9; Sun, 17 Jun 2007 17:42:20 +0200 (CEST)
To: root@localhost.xxxx.xx
Subject: terstgrkgm
Message-Id: <20070617154220.5EB36B80C9@localhost>
Date: Sun, 17 Jun 2007 17:42:20 +0200 (CEST)
From: martinn@localhost.xxxx.xx

ffff

super new #

This the mail that I sent fram martinn to root, so it has gotten here, but when I run the following command:
super new # mail
No mail for root
super new #

Then it says I have no new mail.
Well, is it wrong to use the 'mail' command??
Or am i using it wrong?
I cannot use any graphic mail clients since the mail should be parsed through a script.
But my thought (just now really) is can I parse the files in the /root/.mail/new/ directory and just send them as sms 's and then remove them? wouldn't that do the trick? Or is it any way I can use the 'mail' client to read these mails?
In the near future I would like to include these nagios mails into my CVS system. But maybe the mail files just kan be parsed with cvs, instead of being 'read' with a mail client?

Thanks for help!

\\martinn
Back to top
View user's profile Send private message
buzzin
Apprentice
Apprentice


Joined: 17 Oct 2003
Posts: 264
Location: St. Albans, UK.

PostPosted: Sun Jun 17, 2007 9:52 pm    Post subject: Reply with quote

not quite a fix to your problem... But im thinking that maybe you could install procmail and get postfix to deliver to that. Then you can use procmail rules to do loads of scripting or just call an external script for each mail.
Back to top
View user's profile Send private message
Princess Nell
l33t
l33t


Joined: 15 Apr 2005
Posts: 927

PostPosted: Tue Jun 19, 2007 12:33 am    Post subject: Reply with quote

I would think that /bin/mail doesn't support maildir. Install, even for testing only, a cmd line mail
client like mutt to read those mails.

Yes, procmail is definitely the way to go.
Back to top
View user's profile Send private message
kashani
Advocate
Advocate


Joined: 02 Sep 2002
Posts: 2032
Location: San Francisco

PostPosted: Tue Jun 19, 2007 6:28 am    Post subject: Reply with quote

The mail command does not support maildir so if can't tell you if you have mail.

Personally I wouldn't run any scripts and would instead have Nagios use it's internal logic, which is pretty powerful, to decide whether to send you an email or a page on it's own.

kashani
_________________
Will personally fix your server in exchange for motorcycle related shop tools in good shape.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum