LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 10-30-2009, 06:50 AM   #16
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 9,201

Rep: Reputation: 870Reputation: 870Reputation: 870Reputation: 870Reputation: 870Reputation: 870Reputation: 870

1. A user's home dir is /home/user, so in your case it's /home/kashif. You should put .procmailrc in there.

2. You can put the perl script where you want, just make sure it's executable. For example if you name the script attachment.pl and put it in /usr/local/bin, you have to run:
Code:
chmod +x /usr/local/bin/attachment.pl
You don't need anything in /etc/mail/aliases if you're going to use the procmail approach

3. The code means that if there is an attachment with a .wav extension, then run the command after the "|". That is /usr/local/bin/attachment.pl, if you have created the script like in the step 2 above.

Last edited by bathory; 10-30-2009 at 06:55 PM.
 
Old 10-30-2009, 07:31 AM   #17
Terry56
Member
 
Registered: Oct 2009
Posts: 49

Original Poster
Rep: Reputation: 15
Hi
Just one more question please, sorry the code
Code:
:0 B:
* ^Content-Type: .*;$[ ]*(file)?name=\"?.*\.(wav)\"?$
|/path/to/script.pl
i put this code in the .procmailrc file is it and that's all

Thank you very much
 
Old 10-30-2009, 08:03 AM   #18
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 9,201

Rep: Reputation: 870Reputation: 870Reputation: 870Reputation: 870Reputation: 870Reputation: 870Reputation: 870
Assuming that you have created the perl script and edited it to save the attachments where you want, then this is it.
You should try it, to see if you need to change permissions in the directory where you want the attachments to be saved.
 
Old 10-30-2009, 08:09 AM   #19
Terry56
Member
 
Registered: Oct 2009
Posts: 49

Original Poster
Rep: Reputation: 15
Hi,
Yes i have created the script but i want to ask that when i will make .procmailrc file in /home/kashif then what this file contain, is it empty file or any script or what thing it has to be, this is i am asking.

Thank you
 
Old 10-30-2009, 08:16 AM   #20
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 9,201

Rep: Reputation: 870Reputation: 870Reputation: 870Reputation: 870Reputation: 870Reputation: 870Reputation: 870
.procmailrc should contain the mail filtering rules, that is the following 3 lines:
Code:
:0 B:
* ^Content-Type: .*;$[ ]*(file)?name=\"?.*\.(wav)\"?$
|/path/to/script.pl
 
Old 10-31-2009, 02:25 AM   #21
Terry56
Member
 
Registered: Oct 2009
Posts: 49

Original Poster
Rep: Reputation: 15
Hi,
Thank you for your help but procmail is not working for me, This is my .procmailrc file in /home/kashif which contain the code

Code:
#The code means that if there is an attachment with a .wav extension, #then run the command after the "|". That is /usr/local/bin/attachment.pl
:0 B:
* ^Content-Type: .*;$[ ]*(file)?name=\"?.*\.(wav)\"?$
|/usr/local/bin/attachment.pl
One thing more is i supposed to restart anything after creating this procmailrc file, and will this code is write in one line or copy as it is as you posted means after $ there is line break or not . And in attachment.pl I changed the line like

Code:
#$TMPDIR = "/var/spool/mail/MIME";
$TMPDIR = "/var/spool/asterisk/voicemail/brights/220/INBOX";
INBOX is an empty folder ok in which i suppose to forward voice-mail part of my mail.

I also removed the line kashif: /var/spool/asterisk...... in /etc/aliases but one thing that i want to tell you is that when i was using this line in /etc/aliases then the mail is going to root mail box and it showed that it failed to send mail to var/spool/asterisk.....

Right now mail is going to kashif mailbox

i didn't fine any procmail log also may be it contain something about this any ways and idea where i am doing wrong and any hint or help please
Thanks in advance
 
Old 10-31-2009, 06:48 PM   #22
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 9,201

Rep: Reputation: 870Reputation: 870Reputation: 870Reputation: 870Reputation: 870Reputation: 870Reputation: 870
Are you sure you have procmail installed?
Procmail does not need a restart. It's used by sendmail to deliver mail to the user's mailbox. If it finds a .procmailrc in the user's homedir then it delivers the mail according to the rules in that file.
 
Old 11-02-2009, 01:48 AM   #23
Terry56
Member
 
Registered: Oct 2009
Posts: 49

Original Poster
Rep: Reputation: 15
Hi,
Oh i didn't check it before but rpm -q procmail gave me a resullt like

[root@ns9 ~]# rpm -q procmail
procmail-3.22-14.1.el4

so i think it is installed. Is there any other critaria to check whether it is running or not or running with send mail.

Where is procmail log messages store may be it showed something usuful, while searching i came to know that by inserting verbose = yes in .procmailrc you able to see prcomail log meesages

Or what about the code, there is line break after $ sign or not and what is :0 B: indicating in the code

Thanks in advance
 
Old 11-02-2009, 04:09 AM   #24
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 9,201

Rep: Reputation: 870Reputation: 870Reputation: 870Reputation: 870Reputation: 870Reputation: 870Reputation: 870
Maybe your sendmail is not configured to use procmail (most unlikely). Check sendmail.mc to see if you have procmail as mailer.
If you want to get procmail logs, edit .procmailrc and add at the beginning:
Code:
PMDIR=$HOME/.procmail
LOGFILE=$PMDIR/procmail.log
VERBOSE=on
You have to create the .procmail directory in the user's homedir.
The 2nd line ends at $ and next line starts with | (to run the perl script)
Quote:
what is :0 B: indicating in the code
It tells procmail to grep the body of the email for a .wav extension. Read the procmailrc and procmail manpages for more details.

Regards

Last edited by bathory; 11-02-2009 at 04:28 AM. Reason: more info
 
Old 11-02-2009, 07:38 AM   #25
Terry56
Member
 
Registered: Oct 2009
Posts: 49

Original Poster
Rep: Reputation: 15
Hi,
Thank you. I checked my sendmail.mc and find line like

define(`PROCMAIL_MAILER_PATH',`/usr/bin/procmail')dnl

so is it mean that sendmail is configured with procmail?

Also i create a .procmail directory in the /home/kashif/ but it gives me error in the log i.e.,

Error while writing to "/home/kashif/.procmail/procmail.log

first i only create directory but then i also create a file procmail.log after saw this message but it still shows this error message

Here my .procmailrc file now

PMDIR=$HOME/.procmail
LOGFILE=$PMDIR/procmail.log
VERBOSE=on

# :0 :B tells procmail to grep the body of the email for a .wav #extension. The code means that if there is an attachment with a .wav #extension,then run the command after the
#"|". That is /usr/local/bin/attachment.pl

:0 B:
* ^Content-Type: .*;$[ ]*(file)?name=\"?.*\.(wav)\"?$
"|/usr/local/bin/attachment.pl"

I also read that quotes are necessary around the | and the location so i also put the code but still no progress

Any idea

Thank you
 
Old 11-02-2009, 07:58 AM   #26
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 9,201

Rep: Reputation: 870Reputation: 870Reputation: 870Reputation: 870Reputation: 870Reputation: 870Reputation: 870
The .procmail directory you created must be owned by the user in question (that is kashif). The log file is created automatically, as the user receives his 1st email. Since procmail tried to write to the logs, that means that it works. The fact is that it does not filter the wav attachments somehow.
Are you sure you have removed the .forward and the user alias?

BTW you don't need quotes around the commands in .procmailrc.
 
Old 11-02-2009, 08:18 AM   #27
Terry56
Member
 
Registered: Oct 2009
Posts: 49

Original Poster
Rep: Reputation: 15
Hi,
Thank you. .forward what is this i didn't do any thing with .forward.
Is it in the /etc/aliases file? what should i suppose to do with .forward?

Yes in the /etc/aliases file i remove kashif it is in the form like

kashif: root

but i remove this line but .forward i don't no what is it?

Thank you
 
Old 11-02-2009, 08:32 AM   #28
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 9,201

Rep: Reputation: 870Reputation: 870Reputation: 870Reputation: 870Reputation: 870Reputation: 870Reputation: 870
1. You have to remove the line with kashif from /etc/aliases and run
Code:
newaliases
to rebuild the aliases database.

2. Check that there is not a .forward file in the users home dir
Code:
ls -la /home/kashif/.forward
If it exists rename it to something else to keep it as a backup.
 
Old 11-03-2009, 12:57 AM   #29
Terry56
Member
 
Registered: Oct 2009
Posts: 49

Original Poster
Rep: Reputation: 15
Hi,
I checked as you said. The result is

[root@ns9 ~]# ls -la /home/kashif/.forward
ls: /home/kashif/.forward: No such file or directory

Also my /etc/aliases file doesn't contain kashif.But I have changed the owner and group of .procmail directory and now the log is showing. These are the lines in the log file of procmail.log

procmail: [13734] Tue Nov 3 16:36:12 2009
procmail: No match on "^Content-Type: .*;$[ ]*(file)?name=\"?.*\.(wav)\"?$"
procmail: Locking "/var/mail/kashif.lock"
procmail: Assigning "LASTFOLDER=/var/mail/kashif"
procmail: Opening "/var/mail/kashif"
procmail: Acquiring kernel-lock
procmail: Unlocking "/var/mail/kashif.lock"
procmail: Notified comsat: "kashif@0:/var/mail/kashif"
From basit_mahmood@netkarachi.com Tue Nov 3 16:36:12 2009
Subject: VoiceMail: test voice mail
Folder: /var/mail/kashif 128598

Thank you
 
Old 11-03-2009, 04:10 AM   #30
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 9,201

Rep: Reputation: 870Reputation: 870Reputation: 870Reputation: 870Reputation: 870Reputation: 870Reputation: 870
Quote:
procmail: No match on "^Content-Type: .*;$[ ]*(file)?name=\"?.*\.(wav)\"?$"
I cannot see why it does not match the .wav extension.
Can you try to send an email to that user attaching a .wav file and see what happens?
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
stop incoming mail while quota exceed in openwebmail shan_nathan Linux - Server 1 10-07-2009 09:55 PM
outgoing mail server : timeout error bittus Linux - Newbie 94 11-19-2008 08:16 PM
dd retry on error? SDraconis Linux - General 4 06-12-2005 02:20 AM
increasing retry timeout with mgetty/sendfax? rj1 Linux - General 0 11-10-2004 12:39 AM


All times are GMT -5. The time now is 05:54 PM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration