LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 05-28-2007, 02:16 AM   #1
aeby
Member
 
Registered: Mar 2007
Posts: 109

Rep: Reputation: 15
bash script to send a mail attachment


Hi,
i need to write a bash script to send an attachment via mail from the command line, i know the mail command but i have not been successful in finding an option for it.



Regards,

aeby
 
Old 05-28-2007, 03:46 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,393

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
unrelated to networking. moved to Linux - General
 
Old 05-28-2007, 04:34 AM   #3
aeby
Member
 
Registered: Mar 2007
Posts: 109

Original Poster
Rep: Reputation: 15
how do i move it to general
 
Old 05-28-2007, 04:36 AM   #4
Xeratul
Senior Member
 
Registered: Jun 2006
Location: Debian Land
Posts: 1,335

Rep: Reputation: 83
Quote:
Originally Posted by aeby
how do i move it to general
with sendmail or postfix ...
(my preference is for sendmail)
...
 
Old 05-28-2007, 04:42 AM   #5
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374
Hi,

Can you elaborate on that a bit?

- You talk about a script _and_ the command line. Is the attachment name(s) given to the script from the command line?
- Can the attachment be included in the body of the mail or should it be an attached file.

A rough example, taking attachment name(s) from the command line:
Code:
#!/bin/bash

attachMe="$@"

for thisFile in ${attachMe}
do
  uuencode ${thisFile} ${thisFile} | \
  mailx -s "Subject goes here" someuser@some.place
done
Hope this helps.
 
Old 05-28-2007, 05:32 AM   #6
Xeratul
Senior Member
 
Registered: Jun 2006
Location: Debian Land
Posts: 1,335

Rep: Reputation: 83
almost working ... I received sthg but not right.
I received an email that I cannot read the picture. the yahoo didnt find out that there was a pic inside.

uuencode mypicture.jpg mypicture.jpg | ... ?? is it the best way ?

Quote:
begin 644 mypicture.jpg
M_]C_X``02D9)1@`!`0```0`!``#_VP!#``@&!@<&!0@'!P<)"0@*#!0-#`L+
M#!D2$P\4'1H?'AT:'!

...
blabla
http://www.brandonhutchinson.com/Sen...tachments.html
are you using postfix or sendmail?

(u can private msg me for this topic)

Last edited by Xeratul; 05-28-2007 at 05:43 AM.
 
Old 05-28-2007, 06:13 AM   #7
Xeratul
Senior Member
 
Registered: Jun 2006
Location: Debian Land
Posts: 1,335

Rep: Reputation: 83
it worked !

Code:
mutt &
bla bla
creates sthg

echo "filefilefile " | mutt -a mypicture.jpg  -s "filefile"  user@blabla.com
plz check ur .muttrc

Otherwise, did you manage with mailx or whatever else than mutt??
if yes, please could you let us know?

Last edited by Xeratul; 05-28-2007 at 06:48 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to send email with attachment using "mail"? jonathanztaub Linux - Software 4 05-10-2004 11:53 AM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 12:20 AM
bash script to send mail Cruger Programming 1 03-06-2004 08:25 AM
howto send a mail with attachment via perl script ? cccc Programming 24 03-05-2004 07:49 PM
mail -a would not work to send e-mail attachment saavik Linux - Networking 3 12-18-2003 09:33 AM


All times are GMT -5. The time now is 10:31 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration