Solved

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

Posted on 2009-05-03
9
874 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
AIX print queues constantly going down 11 490
CPU monthly average? 12 107
Java core in Solaris 10 1 262
Linux : can't create transaction lock error 1 59
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
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.

920 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