DBAsupport.com Forums - Powered by vBulletin
Results 1 to 7 of 7

Thread: mailx - How to do attachment?

  1. #1
    Join Date
    Sep 2001
    Location
    Düsseldorf, Germany.
    Posts
    588
    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

  2. #2
    Join Date
    Mar 2001
    Posts
    144
    Here's a sample of the syntax on how to use it:

    /usr/bin/mailx -s "the -s switch is for subject" $recipient < $msgfile

  3. #3
    Join Date
    Sep 2001
    Location
    Düsseldorf, Germany.
    Posts
    588
    Originally posted by ramaral
    /usr/bin/mailx -s "the -s switch is for subject" $recipient < $msgfile
    Hi,

    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?


  4. #4
    Join Date
    Jan 2002
    Location
    Up s**t creek
    Posts
    1,525
    Hi,

    I don't think you can attach files with mailx :(

    (I'm sure someone might be able to prove me wrong )
    Regards

    Jim
    Oracle Certified Professional
    "Build your reputation by helping other people build theirs."

    "Sarcasm may be the lowest form of wit but its still funny"

    Click HERE to vist my website!

  5. #5
    Join Date
    Mar 2001
    Posts
    144
    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]

  6. #6
    Join Date
    Sep 2001
    Location
    Düsseldorf, Germany.
    Posts
    588
    Hey

    This is good..

    Thanks a lot ramaral..

    Sameer

  7. #7
    Join Date
    Feb 2009
    Posts
    2

    Help required

    Quote Originally Posted by ramaral View Post
    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]
    ramaral, I trued this in UNIX (Solaris) it email me the message as a body, the line ~< ! uuencode is not running the uuencode? am I missing something?
    Basicly, I received the email with the ~< ! uuencode as a line?
    Regards
    Joe

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width