flush the mail queue

Hi Guys,

My mail queue is showing a mail.

I want to flush the queue.

Can you let me know how to flush the mail queue.

Regards,
Magesh

Hi,

What OS and what MTA?

Sendmail- sendmail -q command flushes mail queue.
Postfix- postfix flush OR postfix -f

You can try

cp /dev/null /var/spool/mail/your_userid

.
It works fine on AIX.

@ripat,
My OS is SunOs. I do not know what is MTA?

@ proactiveaditya ,

Sendmail is not found in my box.

d003:/var/spool>sendmail -q
ksh: sendmail:  not found

@giannicello ,
mail folder is not found in /var/spool directory.
but the mail command is installed in my box.

d003:/var/spool>which mail
/usr/bin/mail

MTA == Mail Transfer Agent like exim, postfix, qmail, sendmail etc...

Which one do you have?

How to find it out.. sorry i do not know about it.. :frowning:

Try a

netstat -tupel

or

ps aux | grep '\(exim\|mail\|postfix\)'

And look if you find any of the MTA listed above.

this is what i am getting

d003:/cust/home/ds>ps aux | grep '\(exim\|mail\|postfix\)'
usage: ps [ -aAdeflcjLPy ] [ -o format ] [ -t termlist ]
        [ -u userlist ] [ -U userlist ] [ -G grouplist ]
        [ -p proclist ] [ -g pgrplist ] [ -s sidlist ]
  'format' is one or more of:
        user ruser group rgroup uid ruid gid rgid pid ppid pgid sid taskid
        pri opri pcpu pmem vsz rss osz nice class time etime stime
        f s c lwp nlwp psr tty addr wchan fname comm args projid project pset
d003:/cust/home/ds>netstat -tupel
netstat: illegal option -- t
usage: netstat [-anv] [-f address_family]
       netstat [-g | -p | -s] [-n] [-f address_family] [-P protocol]
       netstat -m
       netstat -i [-I interface] [-an] [-f address_family] [interval]
       netstat -r [-anv] [-f address_family|filter]
       netstat -M [-ns] [-f address_family]
       netstat -D [-I interface] [-f address_family]

---------- Post updated at 03:53 PM ---------- Previous update was at 03:45 PM ----------

When i ran the below command i am getting the following output

ps -ef | grep mail

output:

 root   403     1  0   Aug 19 ?        0:09 /usr/lib/sendmail -bd -q15m
   smmsp   397     1  0   Aug 19 ?        0:00 /usr/lib/sendmail -Ac -q15m
    root 22260   403  0 06:22:40 ?        0:00 /usr/lib/sendmail -bd -q15m
   dsdev 22248 21543  0 06:22:25 pts/1    0:00 mail
   dsdev 22251 22250  0 06:22:25 pts/1    0:00 /usr/lib/sendmail -oi -- oot 0 0 0 Aug 19 ? 0:33 sched MAILER-DAEMON
   dsdev 22249 22248  0 06:22:25 pts/1    0:00 sh -c mail oot     0     0  0   Aug 19 ?        0:33 sched MAILER-DAEMON
   dsdev 22250 22249  0 06:22:25 pts/1    0:00 mail oot 0 0 0 Aug 19 ? 0:33 sched MAILER-DAEMON
   dsdev 22268 21543  0 06:22:43 pts/1    0:00 grep mail
    root 22252   403  0 06:22:25 ?        0:00 /usr/lib/sendmail -bd -q15m

Then i think MTA is sendmail

On the SunOs, I do the same

cp /dev/null /var/mail/your_userid

In my case (and probably everyone else's), the /var/mail/my_userid will only exist if I actually have mail or saved mail, otherwise there won't be a file in /var/mail with my userid.
We have a job in cron that removes these daemon emails without any issues...and it's a quick way to purge them all.

can you do:
~> whereis sendmail

Have you found where your mail spool is yet?
If you type
~> mail
The mail program may start and give a clue. (and a long list of messages)
Just type x to close without making any changes.

This is wat my output of whereis command

d003:/cust/home/dsdev>whereis mail
mail: /etc/mail /usr/bin/mail /usr/lib/mail /usr/lib/mail.local /usr/ucb/mail

this is my output of mail command

d003:/cust/home/dsdev>mail
From MAILER-DAEMON Wed Oct  7 10:45:03 2009
Date: Wed, 7 Oct 2009 10:45:03 -0400 (EDT)
From: Mail Delivery Subsystem <MAILER-DAEMON>
Message-Id: <200910071445.n97EbYnK029002@tcmsd003-ipmp.tcc.chrysler.com>
To: <dsdev@tcmsd003-ipmp.tcc.chrysler.com>
Subject: Warning: could not send message for past 4 hours
Content-Length: 1797


*** Message content is not printable: delete, write or save it to a file ***

Re:

d003:/cust/home/dsdev>mail
From MAILER-DAEMON Wed Oct  7 10:45:03 2009
Date: Wed, 7 Oct 2009 10:45:03 -0400 (EDT)
...

Is that the message you want to get rid of?
Your mail is different than mine , but I am using linux. Maybe I should shut up!
I get a list showing each msg header.
I can type "1" to read msg 1 or "d 1" to delete msg 1 etc. I learned how to do that through:
man mail

sendmail may not be in your $PATH
So you may need to add the path to your "sendmail -q" statement.
The ps command you did earlier showed the path to sendmail
I can also do this to find the path:
whereis sendmail

You mean you do not have a /var/spool/mail/dsdev file?