Smart questions
Smart answers
Smart people
Join Tek-Tips Forums

Member Login

Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

yy2 (MIS) (OP)
17 Jul 06 2:55
Can anyone provide the command how to send a text file as a attachment with a proper subject using mailx or sendmail command in UNIX.

Note: I am using HP-UX OS. The file send should be the attachment, not in the message body. In addition, I need to put in the mail subject as well.

daFranze (TechnicalUser)
17 Jul 06 4:04
I am using a script, wich I found in

substitute sender, receptient, servername, yourdomain



# cut some blahblah


echo "From:"
echo "To:"
echo "MIME-Version: 1.0"
echo "Content-Type: multipart/mixed;"
echo ' boundary="PAA08673.1018277622/"'
echo "Subject: set the subject here"
echo "--PAA08673.1018277622/"
echo "Content-Type: text/plain"
cat < $1
echo "--PAA08673.1018277622/"
echo "Content-Type: text/html;"
echo " name=\"$2\""
echo "Content-Disposition: attachment;"
echo " filename=\"$2\""
cat < $2
) | /usr/sbin/sendmail -t

# cut some blahblah

func_send_email mailbody.txt mailattachment.html

Best Regards, Franz
UNIX System Manager from Munich, Germany

christos (IS/IT--Management)
30 Jul 06 1:45
uuencode file.txt file.txt | mailx -s "attached is file"
daFranze (TechnicalUser)
31 Jul 06 3:39
this will not work with (our?) Exchange 2002 SP3

Best Regards, Franz
UNIX System Manager from Munich, Germany

mcolford (MIS)
25 Aug 06 16:51

The 1st argument you indicate on the command line "mailbody.txt" doesn't seem to work.  When I run this script, it only sends the attachment and the message body is blank.




daFranze (TechnicalUser)
29 Aug 06 7:57
hmmm, I have seen problems with attachments but not with mailbodies.
Are you sure you have the same
everywhere? Please replace servername and domainname by the values used by your senderhost

Best Regards, Franz
UNIX System Manager from Munich, Germany

mrn (MIS)
29 Aug 06 8:32

ux2dos yourfilename.txt | uuencode yourfilename | mailx -m -s "test attachment"

make sure you have a relay set in


"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close