Solved

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

Posted on 2009-05-03
9
883 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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
 
LVL 62

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 62

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
sed -- search an replace multiple pattern 11 76
Help stop mail server from sending spam. 27 125
change HISTFILE for root user on AIX 3 78
unix in java example 9 62
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…
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
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.

776 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