Solved

How to attach a file while sending email via mailx or mail?

Posted on 2009-05-03
9
862 Views
Last Modified: 2012-08-13
I would like to attach a file while sending a email via a command line option in a bash script which is getting executed via cron every hour. Please let me know if there is a way to achieve this. Thanks!
0
Comment
Question by:beer9
  • 3
  • 2
  • 2
  • +1
9 Comments
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 24289405
Hi,
unfortunately it is not possible to send email attachments using the command line of mail or ¤ailx.
I'd suggest using 'mutt' instead.

Wmp

0
 

Author Comment

by:beer9
ID: 24289612
How Can I use 'mutt' for sending email with attachment :-)
0
 
LVL 68

Assisted Solution

by:woolmilkporc
woolmilkporc earned 75 total points
ID: 24289653
mutt -a [/path/to/attachment] -s "[subject]" [recipient@domain.tld]
The mail body can be included via normal redirection and/or by using the -i [/path/to/body.txt] parameter.
This is mutt's man page -
http://www.mutt.org/doc/man_page.html
 HTH
wmp
 
 
0
 
LVL 40

Accepted Solution

by:
omarfarid earned 100 total points
ID: 24289697
you can as well do

uuencode filename < filename | mailx -s "my subject" username@domain
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 61

Assisted Solution

by:gheist
gheist earned 75 total points
ID: 24293376
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 24293497
I am not sue which uuencode you are going to use, but the one in the script is using

--base64

which might not be supported in your version
0
 
LVL 61

Expert Comment

by:gheist
ID: 24293531
You can add 8bit also. 99% of internet is able to cope with that.
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 24293597
Why not let 'mutt' do the job? And it's a fine mail client compared to 'mailx', btw.
mutt for Solaris 10 -
ftp://ftp.sunfreeware.com/pub/freeware/sparc/10/mutt-1.5.19-sol10-sparc-local.gz
 
0
 

Author Closing Comment

by:beer9
ID: 31577299
Thank you :-)
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now