LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 10-17-2023, 02:05 AM   #1
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 20.04
Posts: 2,116

Rep: Reputation: 73
Delete sendmail mail queue


I am sudo user pedro on this little cloud server using Ubuntu 22.04 Server

I am trying to delete the mail in the sendmail mail queue, but the file permissions are:

Quote:
pedro@ubuntu:/var/spool$ ls -l /var/spool/
total 16
drwxr-xr-x 3 root root 4096 May 18 02:08 cron
lrwxrwxrwx 1 root root 7 May 18 02:08 mail -> ../mail
drwxr-s--- 2 smmta smmsp 4096 Oct 17 06:41 mqueue
drwxrws--- 2 smmsp smmsp 4096 Oct 17 06:31 mqueue-client
drwx------ 2 syslog adm 4096 Dec 30 2021 rsyslog
pedro@ubuntu:/var/spool$
I can't touch the mail queue!

First I stopped the sendmail service, then tried to delete:

Quote:
pedro@ubuntu:/var/log/apache2$ sudo rm /var/spool/mqueue/*
rm: cannot remove '/var/spool/mqueue/*': No such file or directory
pedro@ubuntu:/var/log/apache2$ cd /var/spool/mqueue
-bash: cd: /var/spool/mqueue: Permission denied

I can see the mail queue with mailq or sendmail -bp, but that also takes a long time to display anything! Minutes!

What is the best way to get rid of the queue?
 
Old 10-17-2023, 12:30 PM   #2
jayjwa
Member
 
Registered: Jul 2003
Location: NY
Distribution: Slackware, Termux
Posts: 795

Rep: Reputation: 254Reputation: 254Reputation: 254
/var/spool/mqueue is your outgoing messages. If something is clogged up, stop Sendmail, become root, and delete files in that directory. Restart Sendmail. You might have a sub directory ".hoststat" in that directory, depending on your setup. Let that be. Note any message will obviously be deleted. Only do this if you made a mistake and the mail can't be sent as usual. I don't know if Ubuntu lets you login as root or not, but the basic idea is you need root permissions.
 
Old 10-18-2023, 12:06 AM   #3
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 20.04
Posts: 2,116

Original Poster
Rep: Reputation: 73
@jaywa

Thanks! I am trying to set up sendmail, as you know from another thread. Now these mails can't be sent, because sendmail is not yet set up right, but sendmail keeps trying to send them.

Best would be a bash script to do this!

I did it like this, hope I didn't break anything!

Quote:
pedro@ubuntu:~$ sudo su
[sudo] password for pedro:
root@ubuntu:/home/pedro# cd /var/spool/mqueue
root@ubuntu:/var/spool/mqueue# dir
df39G7KxTg009686 df39G7LxLs009694 df39H6IT1U018867 df39H6VFPZ018987 qf39G7KxTg009686 qf39G7LxLs009694 qf39H6IT1U018867 qf39H6VFPZ018987
root@ubuntu:/var/spool/mqueue# cd ..
root@ubuntu:/var/spool# service sendmail stop
root@ubuntu:/var/spool# rm -v mqueue/*
removed 'mqueue/df39G7KxTg009686'
removed 'mqueue/df39G7LxLs009694'
removed 'mqueue/df39H6IT1U018867'
removed 'mqueue/df39H6VFPZ018987'
removed 'mqueue/qf39G7KxTg009686'
removed 'mqueue/qf39G7LxLs009694'
removed 'mqueue/qf39H6IT1U018867'
removed 'mqueue/qf39H6VFPZ018987'
root@ubuntu:/var/spool# service sendmail start
root@ubuntu:/var/spool# service sendmail status
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Any chance to get length of run queue and swap queue? emJ4y Programming 1 11-03-2010 02:13 PM
delete mail in mail queue elainelaw Linux - Newbie 5 07-06-2010 02:46 AM
How to untar my tarred mail queue folder back to the sendmail queue directory again? Md.Abul Quashem Linux - Server 6 02-16-2010 08:32 AM
Is it possible for me to write in front of queue in case of message queue? hemanthv414 Linux - Newbie 1 11-17-2008 04:40 PM
Deleted qmail queue /var/qmail/queue tris Linux - Software 0 10-24-2003 11:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 08:13 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration