Solved

Attachments with Sendmail or mailx

Posted on 1998-07-10
14
960 Views
Last Modified: 2013-12-26
I want to be able to use sendmail to send messages and attachments.  
I need to be able to command line mail files.  Any help is appreciated
0
Comment
Question by:flivauda
  • 9
  • 4
14 Comments
 
LVL 1

Expert Comment

by:Staplehead
ID: 1294648
flivauda,

cat MYFILE | mail -t USERNAME

will send MYFILE in the body of a mail message to USERNAME.

is this what you're looking for?

Larry
0
 
LVL 1

Author Comment

by:flivauda
ID: 1294649
No, I want to be able to send binary files as attachments.  I want to have options for x number of attachments and have message text.

Basically if I am at the command line can I send email with attachments using sendmail or mailx?
0
 
LVL 2

Accepted Solution

by:
mlev earned 50 total points
ID: 1294650
AFAIK, this cannot be done with sendmail or mailx since they aren't MIME-aware.
On the other hand, there is a package called "metamail",
available from ftp://thumper.bellcore.com/pub/nsb.
It contains "mailto" - a mailx-like program that can send MIME messages. You can write a script around it to specify multiple attachments on the command line. (I can help with the script if needed.)
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

 
LVL 1

Author Comment

by:flivauda
ID: 1294651
I went to  ftp://thumper.bellcore.com/pub/nsb  and could not find the program mailto am I looking in the wrong place?  which directory is it in, etc?
0
 
LVL 2

Expert Comment

by:mlev
ID: 1294652
ftp://thumper.bellcore.com/pub/nsb/mm2.7.tar.Z
It is the source distribution. You have to compile it.
It contains several programs, mailto being one of them.
0
 
LVL 1

Author Comment

by:flivauda
ID: 1294653
I am trying to get it to complie under redhat Linux 2.0.30 I went into the src/metamail directory adn tried to do a make all and it wont complie.  It says it is missing:
metamail.c:53: sgtty.h: No such file or directory

i need to be able to build and i think it will be what i need.. any help?

Once this is built i can command line send attachments right?
0
 
LVL 1

Author Comment

by:flivauda
ID: 1294654
send me responses to frank@the-abode.com so we can fix it faster and when i get it working i will up the points
0
 
LVL 1

Author Comment

by:flivauda
ID: 1294655
Okay, I think i have it compling.

I now have a metamail executable, but i need to know how to set it up the scripts
0
 
LVL 2

Expert Comment

by:mlev
ID: 1294656
> I am trying to get it to complie under redhat Linux 2.0.30

Too bad I didn't know that in advance :)
Red Hat Linux includes metamail as a ready package.
For Red Hat 4.2 (which I assume you are using), the package is
metamail-2.7-7.i386.rpm.
If you don't already have it installed (check with rpm -q metamail),
just install it from the CD or from a Red Hat mirror, and you should have
/usr/bin/mailto.

Tell me what exactly arguments you want a script to accept
(recipient, subject, CC, files to attach...) and we'll work on a script.


0
 
LVL 1

Author Comment

by:flivauda
ID: 1294657
Okay, I think i have it compling.

I now have a metamail executable, but i need to know how to set it up the scripts
0
 
LVL 2

Expert Comment

by:mlev
ID: 1294658
From: is set automatically.

{
  echo "$message"
  echo '~*'
  echo 0
  echo "$attachment1"
  echo '~*'
  echo 0
  echo "$attachment2"
} | mailto "$to" -s "$subject" >/dev/null
should do the trick.
I was talking, however, of a generic script, so that you could do, e.g.,
mymail joe -s hello -a file1 -a file2

0
 
LVL 1

Author Comment

by:flivauda
ID: 1294659
Okay, I think i have it compling.

I now have a metamail executable, but i need to know how to set it up the scripts
0
 
LVL 1

Author Comment

by:flivauda
ID: 1294660
Okay, I think i have it compling.

I now have a metamail executable, but i need to know how to set it up the scripts
0
 
LVL 1

Author Comment

by:flivauda
ID: 1294661
Can you change the From part?  I want to be able to set which one of my accounts it is coming from.

Also the attachments are called part1.2 part1.3 instead of the real file names..is there a way around this?
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Suggested Solutions

Title # Comments Views Activity
Process filename extension 3 194
method notes when mouse over in eclipse 5 87
sum28 challenge 31 115
fix34  challenge 9 139
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

808 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