Questions tagged [mail-command]

The mail, Mail and mailx command line utilities

Filter by
Sorted by
Tagged with
98
votes
4answers
148k views

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,...
66
votes
8answers
165k views

How do I send HTML email using linux 'mail' command?

mail -s "subject" xxxxx@gmail.com <test.html works, but only for plain text email. What is the correct way to send HTML email using the Linux command mail?
15
votes
2answers
16k views

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?
13
votes
1answer
9k views

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 ...
8
votes
3answers
2k views

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" | ...
8
votes
3answers
15k views

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 ...
7
votes
2answers
10k views

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 hidden1@...
6
votes
3answers
21k views

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/...
6
votes
3answers
7k views

RHEL - Uuencode + mailx = gibberish

I understand uuencode is for encoding files, and mailx sends mail. However, I'm not exactly understanding... Why uuencode file file | mailx -s "subject" email_adress keeps sending messages with the ...
5
votes
3answers
7k views

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. ...
5
votes
1answer
2k views

How can I set an e-mail's headers using /usr/bin/mail?

I have a bunch of scripts on an IBM AIX server's crontab that call the mail command to send myself an e-mail, kinda like this: $ mail -r myon@hakugyokuro.gk -s "Results for `hostname`" myon@...
5
votes
1answer
3k views

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 ...
5
votes
3answers
922 views

How to grab the oldest unread message from `mail` in a script?

In a script I am trying to finish writing now, I need to get the oldest unread message from the current user's mailbox (specifically, I need the subject line for this project). After extracting the ...
5
votes
1answer
2k views

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/...
4
votes
1answer
20k views

Shell script hangs on mail command

I'm finding that a call to the mail command is causing a script to suspend without error. To close the script I have to ctrl-c or issue a kill command on the process id. The pertinent section of ...
4
votes
4answers
1k views

How do I open mail using vim?

I scheduled a task using at. The output of the scheduled job was sent to mail. But the output is quite huge; I prefer reading it in a text editor. Additionally, I don't want to forward the mail, I ...
4
votes
1answer
836 views

Native sendmail commands to operate the mail queue?

I'm on a CentOS 7 server that runs sendmail and unfortunately I'm not allowed to install new packages. Postfix tools are not installed; AFAIK the only tool available is mailq, that permits only to see ...
4
votes
1answer
3k views

How can I forward local *nix mail to an external account while keeping the local copy?

On my Raspbian server, I wish to have local *nix mail delivered locally, as well as to an external address. /home/pi/.forward contains pi,foo@bar.com. I've run sudo dpkg-reconfigure exim4-config with ...
4
votes
3answers
559 views

Standard and portable way to send email from console?

What is the most portable or standard way to send an email from the console or a script on Linux, and possibly Unix?
4
votes
1answer
7k views

mail doesn't work [duplicate]

I'm new to GNU/Linux and I want to send e-mail to other users on my computer (specifically from root to david). I've searched on google and I have tried the following: # mail david Subject: ...
3
votes
3answers
26k views

Set sender name in mail function

How can I set sender name and email address using mail command in shell script.
3
votes
2answers
6k views

Mail vs. mail what is the difference

What is this business about mail and Mail? [On a CentOS box] Why mail does not work but won't return an error either while Mail works fine with the exact same syntax? Mail is basically a link to mail,...
3
votes
1answer
5k views

Maildir and mailutils?

I want to use the mailutils app on a install of Ubuntu 12.04.3 LTS with a Maildir format, but every time I run the mail command, the system looks in /var/mail/user, instead of the Maildir directory in ...
3
votes
1answer
3k views

What should I configure to send mail on the command line?

I am working in the computer at home I want to send me an email and I tried: uuencode all.sh all.sh | mail mymail@gmail.com But the problem is that nothing arrive to my email, I just get the ...
3
votes
4answers
6k views

set up local mail delivery to user from cron script

A line in my cron.daily script not work as expected. I haven't any special smtp mail server in system, this line rsync -avun --inplace /oneuser/file.xls /otheruser/file.xls| mail -s "$0 $?" ...
3
votes
1answer
2k views

How does the mail command work?

I am curious as to how the mail command works. My computer has postfix server installed by default with red hat and is connected to a network that includes a mail server. I had assumed that when I ...
3
votes
2answers
10k views

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 ...
3
votes
1answer
7k views

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 ...
3
votes
1answer
523 views

How can I change the from address in *nix mail globally?

I know that you can change the from address in *nix mail by specifying command-line options. However, is there a way to set it globally, so that it is respected by forwarding? I tried modifying the $...
3
votes
1answer
3k views

Block local (unix) users from sending mail

Is there a way to block a local/unix user (or a list of local users) from sending mails via mail command (or maybe even in postfix, which is the MTA I have).
3
votes
3answers
1k views

How can I connect mail(1) to my Gmail/Yahoo/Hotmail account?

I would like to use the mail command in a shell script to automatically connect to my Gmail/Yahoo/Hotmail account and send/receive messages. How can I do this?
3
votes
2answers
1k views

Can not use mail command

error like this: [user1@fedora ~]$ mail No mail for user1 but that is appear Maildir(mailbox) in /home/user1.
3
votes
2answers
19k views

Mail command to send attachements

I tried the below command uuencode data.txt | mailx –s “Test Mail” “mrp@xyz.com” But I get the below error ksh: uuencode: not found. Null Message body; hope that' ok which clearly tell that ...
2
votes
2answers
801 views

Why is mail-utils / cron sending out so many emails?

I was trying to troubleshoot why my Raspberry Pi isn't sending emails with ssmtp / mail-utils, and so I opened up my gmail account that I use for the Pi. To my surprise, there were 15k unread emails ...
2
votes
2answers
3k views

Where do uncaught local emails go?

Suppose I run - mail goldfish There is no such account on the system and no such aliases defined, where would the mail go? How do I see a list of such mails?
2
votes
1answer
3k views

Trying to send multiple text attachments via mail message

Running this script on: "Red Had Enterprise Linux Server release 5.11 (Tikanga)" Mail is: version 8.1 6/6/93 (appears quite old). Have tried various things and cannot seem to get this to work.. ...
2
votes
1answer
1k views

How do I track down the source of a ssh login message?

I installed mailutils on my linux machine with Linux Mint 15 (basically Ubuntu 13.04). When I log in, I get the following: Welcome to Linux Mint 15 Olivia (GNU/Linux 3.8.0-32-generic i686) Welcome ...
2
votes
1answer
1k views

How do postfix and mailx interact with mbox locking?

If postfix is setup as the MTA using its virtual transport to deliver mail to a local mbox file (and handling delivery of outgoing messages), and mailx is the MUA, being used on that same computer for ...
2
votes
1answer
39 views

How would you build a cron that empties the mail in all mailboxes?

I am new to Unix here. We have some mailboxes that are taking up an incredible amount of space and I'm trying to figure out a way to delete all mail that has been in the box for 30 days. Most of what ...
2
votes
2answers
1k views

sendmail with html and file content

I need to send contents of a file in an email and add some html note at the beginning and ending of the file. I have used "sendmail" for the purpose, however when I receive the email I do not see the ...
2
votes
1answer
2k views

Why cron jobs' output keeps getting written to ~/dead.letter?

I have a job scheduled by cron running every day, and the job is about compressing a folder using tar; and I found that the standard output of tar keeps getting written into ~/dead.letter everyday. ...
2
votes
2answers
96 views

Create a script to check the date, time and string and trigger a mail

Need to create a script where I want to take the last few lines of the log file and check that the last line with Start Date contains the date of today and the time 17:00:xx and is followed by xxxxx ...
2
votes
2answers
440 views

How to get response from mail command

I am trying to send the send email using the mail command as mail -s "subject" email_address < email_text but how will I confirm whether email is actually sent or not ( i.e. email_address is ...
1
vote
2answers
636 views

Trying to direct variable contents into command gives Ambigious Redirect

I'm trying to write a script which tests the http response from various Node servers I have running and which then emails me if any respond with a 502 error from Nginx (meaning one or more server has ...
1
vote
1answer
868 views

Email file attachment from command line

I want to email the file returned by the following command as an attachment (on RHEL/CentOS): ls -1 $(hostname -s)*.xml | tail -n 1 For example, the command above returns server-20140430080511.xml ...
1
vote
1answer
138 views

Does /usr/bin/mail have a queue?

RHEL 5 I'm using a perl service monitoring script (written by a colleague that is no longer with the company) running on an old RHEL 5 box. If a service is down, it sends an email alert to the root ...
1
vote
2answers
63 views

Mail one liner to check if null before sending [duplicate]

I'm trying to modify a script which emails a user group the contents of a directory. The modification I'm looking for is to check the script below to see if it has valid output before sending. The ...
1
vote
1answer
377 views

Why doesn't the list command work in mail?

Why doesn't the list command work in mail? When I try l or list, it doesn't work. It instead gives me a list of the valid commands, including list. Commands are: next, alias, print, type, Type, ...
1
vote
1answer
3k views

On Linux, what is the “mail” user account for?

There's an account mail and a group by the same name on my system, what's its purpose ? It owns the /var/spool/mail directory (empty currently). I plan to use that directory, as well as that user to ...
1
vote
1answer
192 views

sending emails with heirloom, even when Postfix is not running locally

Normally, I can send email from commandline, such as echo hello | mail -s "subject" user@example.com I have noticed that even when Postfix is not running on my machine, I can still "send" emails. ...