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.
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
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.
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
» 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





















