Walker News

A capsule of walker’s experience in life…

Linux Dummy Guide: How To Send Email With Content And Attachment?

For those who are using graphical-based email client should have no problem on how to send an email with attachment.

This dummy guide is for those who want to send an email with content and attachment at the same time in Linux command prompt, not at the Linux Desktop.

But, why you need to do so when there are plenty of email clients appear with intuitive GUI (graphical user interface)?

Well, system administrators or programmers who write Linux shell script to send email with attachments of log file, report, music, picture, etc, will find it easier if working with command-line email client (e.g. sendmail or mail program).

How to send email with attachment in Linux command prompt?

Basically, you need two programs for this topic, i.e. an email client (e.g. mail that bundled with most Linux distributions) and a binary file encoder (e.g. uuencode which is bundled with sharutils package).

For example, to write an email message that’s attached with Logo.JPG:

(echo "This is the content of email and it's attached with a jpeg file called Logo.JPG"; uuencode /tmp/1.JPG Logo.JPG) | mail -s "This is email subject" walker@walkernews.net

The parenthesis groups the both echo and uunencode commands to run as subshell processes, where the output of subshell appears as single input to the mail client.

The uuencode encodes the binary picture file (i.e. /tmp/1.JPG) to ASCII format (i.e. Logo.JPG), which is then sent as email attachment.

If you just want to email attachments without writing the content/message, then the command will be as this:

uuencode /tmp/1.JPG Logo.JPG | mail -s "This is email subject" walker@walkernews.net </dev/null

So, it’s your choice, whether to email attachment with content/message or not. But, those two options are available.


Bookmark and Share:
  • Facebook
  • StumbleUpon
  • Sphinn
  • Digg
  • Pownce
  • del.icio.us
  • Live
  • Google
  • YahooMyWeb
  • Slashdot
  • Furl
  • NewsVine
  • Reddit
  • Ma.gnolia
  • TailRank
  • Technorati
  • BlinkList
  • blogmarks
  • IndianPad
  • Haohao
Topic - Howto, Linux   Search - , , , , , , , , ,

Similar Articles:
» MySQL Dummy Guide: How To Output SQL Results To A Log File?
» MySQL Dummy Guide: How To Display Long SQL Output In Page By Page Fashion?
» Dummy Guide: Introduce Some Simple MySQL Commands
» How To Read ISO Image File In Linux
» Configure Secured Private Key For Password-less SSH Login
» How To Setup Non-Interactive SSH Login
» How To Setup Email Alias In Red Hat Linux

Custom Search

Latest Posts @ WalkerNews.net

↑ Grab this Headline Animator

Navigation:
» HOME - WalkerNews.net
« PREV  - MySQL Dummy Guide: How To Output SQL Results To A Log File?
» NEXT  - Virtual CloneDrive Is Another Virtual CD Drive Emulator

No comments yet. Be the first.

Appreciate your comments, but please be in topic.
Please use proper English with punctuation, from 12th of May 2008 onwards.
WalkerNews.net supports Gravatar (Web ID)