Read all mail linux

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 для борьбы со спамом. Узнайте, как обрабатываются ваши данные комментариев.

Источник

“You have mail” – How to Read Mail in Linux Command Line

This message indicates that there is a message in your spool file. Usually the spool file is in a very simple mbox format, so you can open it in a text viewer like less or with the mail program. In most cases, this is not a message from a long lost lover, but instead a system message generated by your Linux mail service. (sad)

Читайте также:  Настройка разделов для установки windows

View Spool File

Use the following command to read the mail for the currently logged in user. The $(whoami) variable returns the currently logged in user.

You can use the ↑ and ↓ arrows on your keyboard to scroll through the spool file.

Press uppercase G to scroll to the bottom of the file and lowercase q to quit.

If you wish to read another user’s mail, just enter their user name.

Delete Spool File

You can simply delete the /var/mail/username file to delete all emails for a specific user. The $(whoami) variable returns the currently logged in user.

Using the mail Program

You can also use the mail program to easily list and view messages in your spool file. If mail is not installed, you can install it with sudo apt install mailutils .

Messages will be listed with a corresponding number:

After the ? prompt, enter the number of the mail you want to read and press ENTER .

Press ENTER to scroll through the message line by line and press q and ENTER to return to the message list.

To exit mail , type q at the ? prompt and then press ENTER .

Delete All Messages using mail

To delete all messages using mail, after the ? prompt, type d * and press ENTER .

Let me know if this helped. Follow me on Twitter, Facebook and YouTube, or 🍊 buy me a smoothie.

Источник

How to read email received on a Debian server

I have a VPS (virtual private server) running Debian Linux. When I login using PuTTY the console shows — «You have mail»

I have no idea on how to retrieve this email. Which software do I need to install? Which steps to follow?

5 Answers 5

Just type mail , it is the most basic way to read the mail. It should be installed by default on a Debian system, it comes from the mailutils package. Read the man page or type ? to figure out commands to use.

But there are better ways to read the mail. As noted earlier, mailx is an improved version. Even more user-friendly are mutt, cone and (al)pine. All of these are packaged by Debian and can be installed by apt-get

I find the mail program difficult to use. The mail is stored in a flat file, so I use vi /var/spool/mail/user and manage it there.

or

mailx is present by default on most systems. Type mailx to invoke it. Read the manpages to understand how to navigate the mailx interface.

You need some sort of mail client to be configured. I use alpine as it has basic text-GUI and I used it somewhere previously and I am customed to it. Very easy to use, configurable, etc. btw. One way to manage is fetchmail:ing to some other location, if system has mail server installed. Plain .forward file with your mail address in it /home/dir is an option too! Don’t create a loop, though!

Источник

Thread: Server: How do I read my email ?

Thread Tools
Display

Server: How do I read my email ?

I know I have email but I can’t figure out how to read it.
What is the Ubuntu Server 10.10 default email client for reading mail?

Tired net search: ends up talking about setting up a new mail server or post fix or forwarding.
nothing for just reading existing email messages.

Читайте также:  Внутреннее устройство windows руссинович pdf

tried «cant find it»
dpkg -l | grep mail

Re: Server: How do I read my email ?

Don’t you just type mail? I do on all mine.

Re: Server: How do I read my email ?

I don’t recall if it’s installed by default, but alpine is my choice.

Re: Server: How do I read my email ?

neither one is is installed.
«alpine or mail»

I know freebsd is just mail and works default.
Do I have to install one?
I don’t mind; but, I usually like to use the default one’s stuff comes with.
and didn’t want a one floating around that i don’t use or know about.

I used the default free-bsd one like Grenage

Im going to leave this post opened for a two days-
in case «there is or isn’t» a default one that comes with server 10.10 install please reply

Last edited by highspider; April 5th, 2011 at 05:28 PM .

Re: Server: How do I read my email ?

Distro maintainers have to decide which packages are necessary for that distribution’s purposes and which left for later download. These decisions often have little or nothing to do with the quality of the software involved. In the case of Ubuntu, where most releases are designed to fit on a single CD, these decisions are especially difficult ones. There are lots of programs on that CD that you won’t «use or know about,» too.

Most people running servers rarely read mail on the same machine, so there aren’t email clients packaged with Ubuntu Server. Just install alpine from the repositories; you’ll be happy you did.

I actually find it very useful when I need to do mail administration to have a copy of alpine on the server. Here’s an example. I had a client who had some POP3 users (the Chairman and President in particular) who used the «leave mail on server» feature of POP3. Over time their mailboxes grew enormously, but they were unaware of the fact since they only ever saw the new messages in their inboxes. Every six months or so something would happen that would desync the local copy of the mailbox and the copy in /var/spool/mail on the server. Suddenly they’d start getting all their hundreds of messages again because they appeared new. With alpine I could select messages by age, size, etc., and clean things up so the problem wouldn’t recur (for a while). Try deleting only messages whose attachments are greater than, say, 100 MB, by using emacs to edit their mbox files.

In short, if I were packaging the server version of Ubuntu, the two programs I’d definitely want to add to the current distro are alpine and bsd-mailx. The latter I use mostly for testing email services from the command line and to send notices from routine scripts running from cron.

Last edited by SeijiSensei; April 5th, 2011 at 11:15 PM .

Источник

What is the «You have new mail» message in Linux/UNIX?

Sometimes, when I log into a box and ‘su’ to root, I get a cute little message saying I have mail (thank GOD it’s not AOL).

  • Where is this mail?
  • What does it contain?
  • Who/What sent it?
  • How important is it?

Is this even actual «mail» in the same sense as email? Or is it just my system telling me something?

EDIT: In relation to this question, would I be able to send myself mail using the sendmail program like so: email@localhost ?

Читайте также:  Как очистить оперативную память linux

7 Answers 7

Where is this mail?

It’s likely to be in the spool file: /var/mail/$USER or /var/spool/mail/$USER are the most common locations on Linux and BSD.

(Other locations are possible – check if $MAIL is set – but by default, the system only informs you about /var(/spool)/mail .)

Usually the spool file is in a very simple mbox format, so you can open it in a text editor or pager.

For a slightly more convenient way, most distributions come with a program called mail (or Mail , mailx ). You can try mutt or alpine ; you can even configure it to be sent to an outside mailbox. (See «is this real mail?» below.)

What does it contain, and who/what sent it?

Most often the messages contain output of cron jobs, or a system security report by logwatch, or similar junk. Read it and find out.

How important is it?

Depends greatly on the contents of each message.

You should at least scan the subject headers – often people ignore the mail for months never realizing that their daily cron jobs fail.

Is this even actual «mail» in the same sense as email? Or is it just my system telling me something?

Yes to both – it’s generated by your system telling you something, but it’s also actual email and can be handled as such.

You can (and should) configure your mail software – the «MTA» aka /usr/sbin/sendmail – to forward the messages to your personal mail address. The exact instructions vary depending on which MTA (if any) you have installed, whether this is a personal computer or a server, whether you have your own domain or use a @gmail.com, and so on.

Note that /usr/sbin/sendmail nowadays is a shared API and doesn’t necessarily mean the original Sendmail MTA. In fact, you shouldn’t use Sendmail, but something more modern like OpenSMTPD, Postfix, or Exim4. All of them provide the same /usr/sbin/sendmail tool, but they’re easier to configure, more secure, and just as powerful.

The easiest way for me was to run the following in a terminal:

For anyone wondering how to read these messages one by one, you can just use ‘mail’

Then type a message number from the list which you want to read.

To goto the next message you can type ‘next’, another useful command is ‘delete’..

To see more about how the mail program works, see the output of man mail .

Just to offer some clarification, it’s been the tradition for a long time for UNIX boxes to run a «locally configured» mailer daemon that doesn’t route messages through the Internet, but only copies messages to other users spool directories (as @John T mentioned). It is real SMTP-compliant email, it’s just not routed over the Internet because it doesn’t need to be.

So, if you fire up an email client (like alpine or mutt ) you can send mail to other users on the system by addressing to user@hostname , or in many cases, just specifying the user. You also likely have a command line utility called mailx that can be used to send a quick email using your shell.

Now, if you want to send messages to users on systems other than the one you are logged in to, that’s where the real fun begins. You’ll need to configure your mailer daemon to recognize and hand off external email to a transfer agent, configure the transfer agent, and do a whole bunch of stuff I don’t yet understand myself.

Источник

Оцените статью