Hi,
Sorry for posting unix question. But I guess those who worked extensively on unix for them its simple.
How do I send simple text file as attachment using mailx?
or Is it possible to send attachment using mailx.
Thanks
Samee
Printable View
Hi,
Sorry for posting unix question. But I guess those who worked extensively on unix for them its simple.
How do I send simple text file as attachment using mailx?
or Is it possible to send attachment using mailx.
Thanks
Samee
Here's a sample of the syntax on how to use it:
/usr/bin/mailx -s "the -s switch is for subject" $recipient < $msgfile
Hi,Quote:
Originally posted by ramaral
/usr/bin/mailx -s "the -s switch is for subject" $recipient < $msgfile
I don't want to include whole message in the attach file.. Its a log file and in addition to attachment I need to write message body..
what I need is...
-----------------------------------------------
mailx -s "subject" $recipient <<
Backup is complete.. Please see attched logfile
!
.
-----------------------------------------------
For upper syntax where do I specify my attachment file?
Hi,
I don't think you can attach files with mailx :(
(I'm sure someone might be able to prove me wrong :))
Regards
If the file is too big then check out this page for ideas.
http://www.shelldorado.com/articles/...tachments.html
or do something like uuencode the file and pipe it to mailx (something like mentioned in the article but using mailx instead of mail or metasend)
OR
try this sample script:
#!/bin/ksh
# -----------------------------------------------------------------------
# Filename: mailx.ksh
# Purpose: Demonstrates how one can attach files when sending E-Mail
# messages from the Unix mailx utility.
# Author: Frank Naude (frank@ibi.co.za)
# -----------------------------------------------------------------------
SUBJECT="Send mail from Unix with file attachments"
TO=frank\@ibi.co.za
SPOOLFILE=/tmp/sqlplus.txt
echo "Produce listing from SQL*Plus..."
sqlplus -s scott/tiger >$SPOOLFILE <<-EOF
set echo off feed off veri off pages 0 head off
select * from tab;
EOF
# echo "Convert file to DOS mode..."
# unix2dos $SPOOLFILE $SPOOLFILE 2>/dev/null
echo "Send the E-mail message..."
/usr/bin/mailx -s "${SUBJECT}" ${TO} <<-EOF
Hi,
This sample E-mail message demonstrates how one can attach
files when sending messages with the Unix mailx utility.
First attachment: SQL*Plus spool file
~< ! uuencode $SPOOLFILE `basename $SPOOLFILE`
Second attachment: mailx.ksh (this script)
~< ! uuencode mailx.ksh mailx.txt
Third attachment: /etc/passwd file
~< ! uuencode /etc/passwd passwords
Best regards
~.
EOF
echo "Done!"
Found at http://www.orafaq.com/scripts/unix/mailx.txt
[Edited by ramaral on 08-09-2002 at 08:36 AM]
Hey
This is good..
Thanks a lot ramaral..
Sameer