How to send email with attachments from command line
Posted by admin on October 23rd, 2010
This is a quick tip for all those beginers on openSUSE, SUSE Linux or even for that matter on any Linux or Unix distros on how to send an email from command line with an attachment. This could be a text or an image file.
By default, mail messages can be encoded with the file content into the mail message body rather than adding the required file as an attachment. To send a file as an attachment use the “uuencode” utility as follows:
Annai~ # uuencode filename.png filename.png | mailx -s “mail subject” receiver@address.com
In the above, uuencode writes an encoded version of the file (filename.png here) which is then piped to the mailx command.
This ofcourse assumes, you have your system is configured to send emails. In openSUSE, SuSE linux, click here to know how to configure Postfix to send emails.

October 23rd, 2010 at 6:51 am
much simpler:
mail -s “subject” -a “filename”
October 23rd, 2010 at 6:54 am
mailx [-BDdFintv~] [-R address ] [-s subject] [-a attachment ] [-c cc-addr] [-b bcc-addr] [-r from-addr] [-h hops] [-A account] [-S variable[=value]] to-addr . . .
October 23rd, 2010 at 7:28 am
why so complicated?
mutt -s subject -a file1 -a file2 receivert@example.com
October 23rd, 2010 at 8:42 am
You can also use mail , e.g. :
# mail -a filename -s “you subject” mail@mail.com
October 23rd, 2010 at 12:51 pm
kmail –attach -s foo@bar.org does it too.
October 26th, 2010 at 6:22 pm
howzit folks?
these tips are helpful but what i’ve been struggling with is trying to send spam email as an attachment to spamcop within kmail using the filter actions. Does anyone have any bright ideas to do this?
cheers
aztrix