send mail from linux terminal in one line
mail can represent quite a couple of programs on a linux system. What you want behind it is either sendmail or postfix. I recommend the latter.
You can install it via your favorite package manager. Then you have to configure it, and once you have done that, you can send email like this:
echo "My message" | mail -s subject user@gmail.com
See the manual for more information.
As far as configuring postfix goes, there's plenty of articles on the internet on how to do it.
Unless you're on a public server with a registered domain, you generally want to forward the email to a SMTP server that you can send email from.
For gmail, for example, follow
http://rtcamp.com/tutorials/linux/ubuntu-postfix-gmail-smtp/
or any other similar tutorial.
How to send email from Terminal?
Go into Terminal and type man mail
for help.
You will need to set SMTP
up:
http://hints.macworld.com/article.php?story=20081217161612647
See also:
http://www.mactricksandtips.com/2008/09/send-mail-over-your-network.html
Eg:
mail -s "hello" "example@example.com" <<EOF
hello
world
EOF
This will send an email to example@example.com
with the subject hello
and the message
Hello
World
How do I Send Email from the Command Line?
You can use mail:
$mail -s <subject> <recipients>
You then type your message and end it with a line that has only a period. This signals you are done and sends the message.
You can also pipe your email in from STDIN and it will be sent as the text of an email:
$<mail-generating-program> | mail -s <subject> <recipients>
One small note with this approach - unless your computer is connected to the internet and your DNS settings are set properly, you won't be able to receive replies to your message. For a more robust command-line program you can link to your POP or IMAP email account, check out either pine or mutt.
How do I send a file as an email attachment using Linux command line?
None of the mutt ones worked for me. It was thinking the email address was part of the attachment. Had to do:
echo "This is the message body" | mutt -a "/path/to/file.to.attach" -s "subject of message" -- recipient@domain.example
Specify the from user when sending email using the mail command
http://www.mindspill.org/962 seems to have a solution.
Essentially:
echo "This is the main body of the mail" | mail -s "Subject of the Email" recipent_address@example.com -- -f from_user@example.com
Related Topics
Grep Without Showing Path/File:Line
Getting CPU Cycles Using Rdtsc - Why Does the Value of Rdtsc Always Increase
Linux Time Command Microseconds or Better Accuracy
How to Download a Tarball from Github Using Curl
How to Get a List of Available Wireless Networks on Linux
Library Path When Dynamically Loaded
How to Force Abort on "Glibc Detected *** Free(): Invalid Pointer"
Bash: Integer Expression Expected
How Would I Get a Cron Job to Run Every 30 Minutes
Linux: Find All Symlinks of a Given 'Original' File? (Reverse 'Readlink')
Running Shell Script in Parallel
How to Decode /Proc/Pid/Pagemap Entries in Linux
What's the Point of Eval/Bash -C as Opposed to Just Evaluating a Variable
How to Use Arrow Keys Alone to Expand Tree Node in Package Explorer in Eclipse on Linux
Where Are Include Files Stored - Ubuntu Linux, Gcc
How to Add a Line of Text to the Middle of a File Using Bash