Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

mailx attachements

Posted on 2002-06-06
10
7,511 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

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