Solved

mailx attachements

Posted on 2002-06-06
10
7,507 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
ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
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…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

810 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