Questions tagged [mail-command]

The mail, Mail and mailx command line utilities

Unix has included a mail command] since version 1, when mails were only delivered to other users of the same machine. Today, all unix variants include a command called mail which can send and receive Internet email, but its capabilities vary. Some systems include a Mail or mailx command as well.

Use this tag if you have a question about the mail, Mail or mailx utility. Be sure to mention what operating system and distribution you are using.

If your question is about email in general, use the tag .

The mailx command is standardized in POSIX.

120 questions
119
votes
3 answers

What is "mail", and how is it navigated?

The program is located in /usr/bin/mail. Upon execution, Version 8.1.2 01/15/2001 is shown. Entering list produces: Commands are: next, alias, print, type, Type, Print, visual, top, touch, preserve, delete, dp, dt, undelete, unset, mail, mbox,…
cwd
  • 44,479
  • 71
  • 146
  • 167
79
votes
9 answers
40
votes
1 answer

How can I list the messages in my mailbox?

Using the mail command it shows the messages I have and drops me into a prompt, but I cannot figure how to list the messages. Here is the help screen for mail: Mail Command Description ------------------------- …
Tyler Durden
  • 5,411
  • 16
  • 57
  • 96
20
votes
2 answers

Does the mail command require a mail server?

Does one need to set up a mail server before being able to use the linux mail command?
puk
  • 333
  • 1
  • 2
  • 10
19
votes
3 answers

Set sender name in mail function

How can I set sender name and email address using mail command in shell script.
Ankur
  • 303
  • 1
  • 2
  • 5
15
votes
3 answers

Delete a range of email messages using the 'mail' command

I have about 1k+ mails in an inbox (old cronjob stdout). How do I delete them in bulk? I'm on Solaris 8 and I have only mail available, no pine or mutt or similar "UI"-based client. Inline help and man page only give d # to delete a specific mail.…
GWu
  • 263
  • 1
  • 2
  • 7
9
votes
2 answers

How can I bcc with mailx?

I'm trying to send unix mail (heirloom-mailx) via bcc. $ mail -V 12.5 6/20/10 My MTA is exim, which sends via Gmail SMTP. I can execute the following: echo -e "body" | mail -s 'subject' -b [email protected],[email protected]
Sparhawk
  • 19,561
  • 18
  • 86
  • 152
9
votes
4 answers

Need to delete mails for a range of dates in Linux

I have 1 million mails generated in a Linux sever due to a cron job. I want to delete the mails, but not all as this cron mails useful to troubleshoot and find out the issue with cron job's execution. So I need to keep 1 month's mail and remove the…
ksk.eaknath
  • 91
  • 1
  • 1
  • 2
8
votes
1 answer

How can I automatically forward system mail?

I have a system job that fails and sensd me mail that I can read with the mail command. That means I still need to login to the mail server to get the emails and read them. The server supports sending mail to external clients, such as gmail. How can…
j0h
  • 3,467
  • 8
  • 27
  • 36
8
votes
3 answers

Executing mail command from inside a function causes a "fork bomb"

When I try to execute mail from inside a function in a bash script it creates something similar to a fork bomb. To clarify, this creates the issue: #!/bin/bash mail() { echo "Free of oxens" | mail -s "Do you want to play chicken with the void?"…
roxto
  • 708
  • 4
  • 12
7
votes
3 answers

HTML email from heirloom mailx on linux

I've been trying to work through sending a html email from mailx on a linux server. Few Notes: I have to specify a smtp server so therefore I cannot use sendmail (This is not something I can change on my end) I cannot install 3rd party things such…
FzZB03KCa46QeaU
  • 91
  • 1
  • 2
  • 8
7
votes
3 answers

Delete Mail Based on Subject Pattern [mail-command]

Is it possible to delete all mail in which the subject matches a regex pattern? For example, to delete message 1, you do: d 1 But to delete all mail with subject starting with, say, [SPAM], I can't do: d -s "^\[SPAM\].*$"
nehcsivart
  • 621
  • 7
  • 13
7
votes
3 answers

Setting headers using the /bin/mail command

I have a bash script that I use with nagios that sends notifications by email. The key part of it looks like this: # $1 (FROM) | $2 (TO) | $3 (SUBJECT) | $4 (BODY) /usr/bin/printf "%b" "$4" | /bin/mail -s "$3" "$2" -- -f $1 I know I could use the…
Kev
  • 1,429
  • 7
  • 21
  • 32
6
votes
1 answer

systemd MAILTO-replacement failing

I'm trying to setup systemd to notify me via email if a unit fails, like Cron can be set up to do. I followed the guide on the Arch Linux wiki. So I set-up a sendmail shell script in /usr/local/bin/systemd-email: #!/bin/bash /usr/bin/sendmail -t…
emacsomancer
  • 499
  • 6
  • 18
6
votes
2 answers

When does Linux send a root mail and how to force it for testing purposes?

Let's say I want to test root mail functionality after I set up nullmailer, how do I force my Debian Linux system to send a root mail? And furthermore on which events does Linux send root mails at all?
JohnnyFromBF
  • 3,476
  • 10
  • 32
  • 42
1
2 3 4 5 6 7 8