Link to home
Start Free TrialLog in
Avatar of ammartahir1978
ammartahir1978Flag for United Kingdom of Great Britain and Northern Ireland

asked on

how to query mail quesues in postfix

hi everyone,

i have linux Suse 10.3 and runing postfix,

i want to query the mail quesues, or how can i transfer the deferred queue mails in to a csv file?

pleas ehelp
Avatar of dramdrum
dramdrum

The command:

mailq

will show you the mail queue along with the reasons mails havent been sent yet

postcat -q queuenumber

will show you the contents of the mail queuenumber

Avatar of ammartahir1978

ASKER

thanks dramdrum, but i want to have all the deferred one's in a csv format so that i can take them out from the mailing list, and through your command i would be sitting there for ever to note down

anymore help please
Also postqueue -p is the same as mailq (mailq might not be available on all systems)

You can do a man postqueue and man postcat to see the full options list
hi dramdum,

i am a beginner so you have to teach me if you dont mind, how can i get all the deffered queue messages in a csv file?
all i need is MAIL ID , EMAIL ADDRESS, And the error in a csv file
postqueue -p
will print out all that info

To automatically extract only those 3 fields for only the deffered mails from the output you will need some serious bash/perl scripting abilities, considering the output is in columns and more than one line for each record.

Unfortunatelly mine are not that good yet ;)

I am sure there is a scripting expert around who will help you out with this. :)
is there any way i can extract everything and then i can sort it in excel myslef?
ASKER CERTIFIED SOLUTION
Avatar of dramdrum
dramdrum

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thank you dramdrum, last think how can i email this file to an external email address, i have copied it to the root > desktop
The easiest way is with mutt:

mutt -s "Here are the deferred mails" -a filename.cvs user@domain.com
it says mutt command not found

anyother way?
Well since it is a text file you could just use the simple mail command and put it in the message body (mail cant handle attachments):

mail -s "Here are the deferred mails" > user@domain.com < filename.cvs
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
its saying no such file found, but it is sitting on the desktop of the root name

 mail -s "here is the file" > atahir@domain.co.uk < /root/desktop/email.xls


but it says file notfound
mail -s "Here are the deferred mails"  user@domain.com < filename.cvs

i have used the above command and it doesnt give me any error but i havent received the email .

how can i check
Take a look if its in the mail queue (with postqueue -p of course)
Look at the mail logs in /var/log/mail.log or /var/log/syslog
it is in the mail queue dramdrum
now mail queue is empty but i havent received it
okay if i dont type < email.csv at the end i get the email straight away but when i do email.csv at the end of the command it does send but i never receive it.

how can i get it
Hmm how big is the file?
Mail queues have a size limit (i think the default is 10MB)
its definately less then 10MB
its 774 KB
I see you closed the question.
You managed to get the file?
yeah well not with your command but what i did is log on to that machine on my web account and emailed that file across :) i know its a way around but i really need to make it working some how so that i can email this file to myself from anywhere in the world.

have you got any other suggestions?