mailx attachements

Hi..........
How do i send email from the command line using mailx.
how do specify:
to
from
subject
attachements
...R
LVL 3
rickyrAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
ahoffmannConnect With a Mentor Commented:
#! /usr/bin/perl
use MIME::Lite;
if ($#ARGV < 3) {
        print "usage: $0 <to> <subject> <text file> <attachement file>\n";
        exit( 1 );
} else {
        $to     = shift;
        $subject= shift;
        $text   = shift;
        $file   = shift;
}
$data     = `cat $text`;
$msg = new MIME::Lite
  From     => 'user@some.where',
  To       => $to,
  Subject  => $subject,
  Type     => 'multipart/mixed';
attach $msg
  Type     => 'TEXT/plain',
  Data     => $data;
attach $msg
  Type     => 'application/pdf';
  Encoding => 'base64',
  Path     => $file;
#print $msg->print_header;
#print $msg->header_as_string;
#print $msg->print_body;
#print $msg->body_as_string;

$msg->send;
exit 0;
0
 
ahoffmannCommented:
> to
mailx to@some.where

> from
not possibly, usually (except you give UNIX flaviour and version, and mailx version)

> subject
mailx -ssubject ...

> attachements
not possible, usually
or see http://www.experts-exchange.com/unix/Q_20305167.html
or see "from" comment above
0
 
yuzhCommented:
As  ahoffmann told you, it is not possible to do this with mailx.

You can use GUI mail client in Solaris, set your DISPLAY,
type in :

/usr/dt/bin/dtmail

Will allow you do the job
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
samriCommented:
rickyr,

Or maybe you could encode the file (maybe using uuencode) first, and pipe it to mailx, it might work.

cheers
0
 
ahoffmannCommented:
> .. uuencode .. pipe .. mail .. it might work
NO.
It does not produce a MIME attachement.
0
 
rickyrAuthor Commented:
I am thinking of using a perl module to do this!
whoever sends the most complete example gets an "A"
............R
0
 
haegerCommented:
I think that I've sent attachments from IRIX via mailx. It's been tarfiles and gzipped files.

mailx -s the_subject someone@somewhere.com < the_file

I'm certain that I've sent textfiles this way.
0
 
ahoffmannCommented:
haeger, you can send files this way, but it is not an attachement, just plain text
0
 
GnsCommented:
So true ahoffmann.

On systems that only provide mailx as MUA, you can be lucky and have the metamail package. And even more lucky, so that mailx actually has been configured to filter inbound mail through it.
For outbound "attachments", you'd have to use some metamail command like mimeencode, mimesend or somesuch.

This is the case with Data Generals crufty ol' DG/UX.

But if you're set on perl, more power to you.

-- Glenn
0
 
rickyrAuthor Commented:
better late than never!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.