Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 913
  • Last Modified:

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

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
beer9
Asked:
beer9
  • 3
  • 2
  • 2
  • +1
3 Solutions
 
woolmilkporcCommented:
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
 
beer9Author Commented:
How Can I use 'mutt' for sending email with attachment :-)
0
 
woolmilkporcCommented:
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
omarfaridCommented:
you can as well do

uuencode filename < filename | mailx -s "my subject" username@domain
0
 
omarfaridCommented:
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
 
gheistCommented:
You can add 8bit also. 99% of internet is able to cope with that.
0
 
woolmilkporcCommented:
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
 
beer9Author Commented:
Thank you :-)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now