We help IT Professionals succeed at work.

Attachments with Sendmail or mailx

flivauda
flivauda asked
on
Medium Priority
980 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
Comment
Watch Question

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

Author

Commented:
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?
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
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?

Commented:
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.

Author

Commented:
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?

Author

Commented:
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

Author

Commented:
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

Commented:
> 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.


Author

Commented:
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

Commented:
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

Author

Commented:
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

Author

Commented:
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

Author

Commented:
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?
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.