Solved

mailx attachements

Posted on 2002-06-06
10
7,501 Views
Last Modified: 2013-12-16
Hi..........
How do i send email from the command line using mailx.
how do specify:
to
from
subject
attachements
...R
0
Comment
Question by:rickyr
10 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7059918
> 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
 
LVL 38

Expert Comment

by:yuzh
ID: 7060914
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
 
LVL 15

Expert Comment

by:samri
ID: 7072400
rickyr,

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

cheers
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7072541
> .. uuencode .. pipe .. mail .. it might work
NO.
It does not produce a MIME attachement.
0
 
LVL 3

Author Comment

by:rickyr
ID: 7072555
I am thinking of using a perl module to do this!
whoever sends the most complete example gets an "A"
............R
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 51

Accepted Solution

by:
ahoffmann earned 200 total points
ID: 7072590
#! /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
 
LVL 1

Expert Comment

by:haeger
ID: 7111763
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7111874
haeger, you can send files this way, but it is not an attachement, just plain text
0
 
LVL 20

Expert Comment

by:Gns
ID: 7217478
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
 
LVL 3

Author Comment

by:rickyr
ID: 7217540
better late than never!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Generate FIPS 140-2 Public Key on Unix 5 67
Host issue and need to move VM's 2 245
reinstall 1 70
Parsing a file using ksh 10 58
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

862 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now