Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2009-05-03
9
890 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

860 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