Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
Find the answer to your Linux question:
New to Linux Forums? Register here for free!
    Linux Forums > GNU Linux Zone > Linux Programming & Scripting > How to attach a file in Linux mail command

Forgot Password?
 Linux Programming & Scripting   C, Perl, PHP, Bash Scripts, anything programming or script related post in here!

Site Navigation
Linux Articles
Linux Forums
Linux Downloads
Linux Hosting
Free Magazines
Job Board
IRC Chat
RSS Feeds


Linux Forum Topics
Linux Forums
Your Distro
Linux Resources
GNU Linux Zone
The Community
Reply
 
Thread Tools Display Modes
Old 12-03-2008   #1 (permalink)
Just Joined!
 
Sangal-Arun's Avatar
 
Join Date: May 2006
Location: Gurgaon, India + Denver Colorado USA
Posts: 97
Send a message via Yahoo to Sangal-Arun
Question How to attach a file in Linux mail command

Hi Guys,

Is there any way to attach a file in Linux mail command without using "uuencode"?

i.e.

Code:
file=/a/b/c/d/file.txt

mail -s "Giga aks" abc@123.com <<HDoc
`uuencode $file $file 2>/dev/null`
HDoc
Here, I don;t want to use 'uuencode' command but want $file to be sent in the email as an attachment.

thanks-
arun
Sangal-Arun is offline  


Reply With Quote
Old 12-03-2008   #2 (permalink)
Just Joined!
 
Sangal-Arun's Avatar
 
Join Date: May 2006
Location: Gurgaon, India + Denver Colorado USA
Posts: 97
Send a message via Yahoo to Sangal-Arun
Also, when I'm putting the below code (PSee inside `` backquotes) i.e. calling uuencode withing a for loop inside another parent for loop, something strange is happening.

Quote:
`for comp in $(ls -c Directory); do echo $comp;echo ===========; for file in $(find Directory/$comp -type f); do uuencode $file $file 2>/dev/null; done ; done`
Instead of showing each component in the email body and attaching the files under each $comp (a subfolder), this command is making a .txt file of the echo statement (except for the first iteration) i.e. for (echo $comp and echo ============ and attaching it in the email.

I want the output like:
---------------------------------------------------
HTML Code:
subfolder1
===========
<path1>/file1 <path1>/file2 <path1>/file3

subfolder2
===========
<path2>/file4 <path2>/file5
---------------------------------------------------

Where, subfolder[12] are 2 folders inder Directory folder and path[12] are 2 different path which will be shown in the attachments/attached files in the email. and file[12345] are the files under those subfolders.

Note: Subfolder[12] and "===========" line under it should come in the email as simple text but the files under that should be shown as attachments under each subfolder[?] (which i think in using Linux Mail command is not possible as you have to configure your outlook email appliation).

Doesn't matter if I get the file[12345] in my email ...all together as attachments..as anyone can easily see the <path?> of a file[?] making a feel that this file is at that path. But, by using the above command within ``(backquotes)... what Linux is doing is:

Im getting only the following in the email body as text data :
---------------------------------------------------
HTML Code:
subfolder1
===========
---------------------------------------------------

and
the below things are showing up as attached files... including the echo statement for 2nd subfolder2 and ========== line.

<path1>/file1 <path1>/file2 <path1>/file3

subfolder2
===========
<path2>/file4 <path2>/file5



If you want to try ... just create a folder Directory using another folder which contains some sub folders and files under that... and you'll get to know what i want to achieve.

I can provide more information in case anyone needs.
Thanks-

Arun Sangal
001 - 303 397 6059
Sangal-Arun is offline   Reply With Quote
Old 12-04-2008   #3 (permalink)
Just Joined!
 
Join Date: Nov 2007
Posts: 9
The Mutt E-Mail Client

Try this one..
JATA01 is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Free Magazines
Run Your Own Web Server Using Linux & Apache - Free 191 Page Preview
Learn about everything you'll need to build and maintain your Linux servers, and to deploy Web applications to them.
subscribe
Open Source Security Myths Dispelled
Dispel the five major myths surrounding Open Source Security and gain the tools necessary to make a truly informed decision for your IT organization
subscribe
InformationWeek
InformationWeek is the only newsweekly you'll need to stay on top of the latest developments in information technology.
subscribe



All times are GMT. The time now is 05:49 AM.






© 2000 - 2009 - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.3.0 RC2