Меню Рубрики

Linux mail delete all messages

How do I purge a linux mail box with huge number of emails? [closed]

Want to improve this question? Update the question so it’s on-topic for Stack Overflow.

Closed 4 years ago .

I have setup some cron jobs and they send the crons result to an email. Now over the months I have accumulated a huge number of emails.

Now my question is how can I purge all those emails from my mailbox?

8 Answers 8

You can simply delete the /var/mail/username file to delete all emails for a specific user. Also, emails that are outgoing but have not yet been sent will be stored in /var/spool/mqueue .

-N Inhibits the initial display of message headers when reading mail or editing a mail folder.
d * delete all mails

Which will delete all messages between number 1 and 15. to delete all, use the d * .

I just used this myself on ubuntu 12.04.4, and it worked like a charm.

Then check your mail again:

What is tripping you up is you are using x or exit to quit which rolls back the changes during that session.

Rather than deleting, I think we can nullify the file, because the file will be created if the mail service is still on. Something like following will do the job

And yes, sorry for awakening this old thread but I felt I could contribute.

On UNIX / Linux / Mac OS X you can copy and override files, can’t you? So how about this solution:

If you’re using cyrus/sasl/imap on your mailserver, then one fast and efficient way to purge everything in a mailbox that is older then number of days specified is to use cyrus/imap ipurge command. For example, here is an example removing everything (be carefull!!), older then 30 days from user vleo. Notice, that you must be logged in as cyrus (imap mail administrator) user:

]$ /usr/lib/cyrus-imapd/ipurge -f -d 30 user.vleo Working on user.vleo. total messages 4 total bytes 113183 Deleted messages 0 Deleted bytes 0 Remaining messages 4 Remaining bytes 113183

Rather than use «d», why not «p». I am not sure if the «p *» will work. I didn’t try that. You can; however use the following script»

Источник

UNIX for Dummies Questions & Answers

How to delete all email messages at ONE time?

These are some of the mail command:

Usage:
? print this help message
# display message number #
— print previous
+ next (no delete)
! cmd execute cmd
next (no delete)
a position at and read newly arrived mail
d [#] delete message # (default current message)
dp delete current message and print the next
dq delete current message and exit
h a display all headers
h d display headers of letters scheduled for deletion
h [#] display headers around # (default current message)
m user mail (and delete) current message to user
n next (no delete)
p print (override any warnings of binary content)
P override default ‘brief’ mode and display ALL header lines
q, ^D quit
r [args] reply to (and delete) current letter via mail [args]
s [files] save (and delete) current message (default mbox)
u [#] undelete message # (default current message)
w [files] save (and delete) current message without header
x exit without changing mail
y [files] save (and delete) current message (default mbox)

Is there 1 command to delete all your email?

Источник

linux-notes.org

Команды /Mail/mailx используемые в операционных систем UNIX/Linux для отправки электронной почты (так же, для полученные и чтения сообщений электронной почты) с возможностью удалять. В своей статье «Команды mail/mailx в примера на Unix/Linux» я расскажу как установить и использовать утилиту (команду) mail на ОС Unix или Linux.

Синтаксис команды mail:

Опции.

-v : Подробный режим. Детали отправки отображаются на экране.
-s : Опция задает тему для письма.
-c : Отправить СС (копии для других пользователей).
-b :Отправить BС (копии для других пользователей).
-f : Прочитать содержимое почтового ящика.
-e : Проверка на наличие почты в почтовом ящике.
-F : Записывает сообщение в файл с именем после получения.
-r : Опция для указания адреса отправителя в настройках отправки почты.
-u : Определяет сокращенния, аналог опции «mail -f /var/spool/mail/UserID».

Установка утилиты mail в Unix/Linux

Для того чтобы установить утилиту mail на CentOS/Fedora/RedHat, используйте:

Для того чтобы установить утилиту mail на Debian/Mint, используйте:

Теперь вы должны иметь команду mail, и можно приступать к работе.

Команды mail/mailx в примера на Unix/Linux

В своей статье «Команды mail/mailx в примера на Unix/Linux» я расскажу как пользоваться утилитой mail в ОС Unix/Linux. Приведу наглядные примеры использования данной утилиты.

Чтобы запустить программу «mail» и вывести список сообщений в почтовом ящике, выполните:

Команда mail показывает количество сообщений в ящике системы. Затем почтовая система отображает подсказку почтового ящика (?), ожидая ввода.

Когда вы видите эту строку, то нужно ввести субкоманду, чтобы увидеть список подкоманд, нужно нажать (?):

Данная команда (?) покажет все субкоманды для Mail.

Отправка электронной почты пользователю:

В команде «echo» задается некоторый текст для отправки по электронной почте.

Опция «-s» используется для указания темы для письма. Собственно, команда mail отправит емейл пользователю send_to_some@email.com. Можно обойтись и без команды echo, тогда команда будет выглядеть следующим образом:

В этом примере вы тогда, будите вводить в сообщении и чтобы остановить просто введите точку следующим образом (.):

Если вы хотите отправить письмо нескольким пользователям, то просто добавить емейл через пробел. Это будет выглядеть следующим образом:

Отправка содержимого текстового файла

3 thoughts on “ Команды mail/mailx в примера на Unix/Linux ”

Не подскажете, как настроить на свой почтовый адрес?

Установить и настроить свой почтовый сервер. Какой взять, — это на любителя. Я предпочитаю — postfix + dovecot. Настройку данной связки я опубликовывал тут: http://linux-notes.org/ustanovka-pochtovogo-servera-postfix-dovecot-i-squirrelmail-v-centos-redhat-fedora/

Если у меня все письма в первый экран не влазят, как увидеть следующую страницу списка?

Добавить комментарий Отменить ответ

Этот сайт использует Akismet для борьбы со спамом. Узнайте как обрабатываются ваши данные комментариев.

Источник

Delete all mails from inbox using linux command prompt

How can I delete emails from an individual email account? e.g. how can I empty userxyz@mydomain.com?

I know the following:

I have many inboxes some of them contain important email I don’t want to delete.

I tried delete all data in user mail cur/ and new/ in the following folder but when checked user quota still was the same.

Just to let you know I’m using CentOS.

1 Answer 1

If you have a mail client like mutt available you can open those files directly like so:

It may prompt you to create the following folder, $HOME/Mail , just say no ( n ) to this question.

/root/Mail does not exist. Create it? ([yes]/no):

You’ll then be able to use t to tag any emails you don’t want to keep. Once they’ve been tagged type the letter d to delete them.

Then simply exit mutt when you’re done, q .

Источник

Clear/Delete/Flush Queued Mail In Sendmail

You can permanently delete all email messages in the Sendmail Mail Server (SMTP) queue using Linux command line. To check the summary of the queued mail messages you can use the mailq or sendmail -bp command. Execute the following command.

Check Queued Mail

You will get some output like below:

Delete All Queued Mail

If you want to delete all queued mail just cd to /var/spool/mqueue/ and delete all files.

Note: Please make sure you are removing all /var/spool/mqueue/ files if you did something wrong with rm -rvf with * you may damage your system.

Delete Queued Mail Using qtool.pl Tool

Sendmail mail server does not provide any command to delete messages from the mail queue. You can use qtool.pl script located in sendmail source code contrib directory as follows:

Now note down Q-ID such as v3K6kjED005817 and run the qtool.pl like below:

  • -C /etc/mail/sendmail.cf :- Specify sendmail config file
  • -d /var/spool/mqueue/ v3K6kjED005817 :- Delete mail specified by source. In this case by Q-ID.

If you want to delete all queued mail for the example.com domail. You will need to set QIDS either using the mailq command or manually like below.

Now follow the base for loop to delete all queued mail for example.com.

I hope this article will help you to flush queued mail in Sendmail. If you have any queries and problem please comment in comment section.

If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com . To become an author at Look Linux Submit Article . Stay connected to Facebook .

About the author

Santosh Prasad

Hi! I’m Santosh and I’m here to post some cool article for you. If you have any query and suggestion please comment in comment section.

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *

  • Mac os секреты советы
  • Mac os сглаживание шрифтов
  • Mac os связка ключей не найдена
  • Mac os свойства папки защита
  • Mac os свернуть приложение