Member Login

Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • 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.

mailx or sendmail command

mailx or sendmail command

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.

RE: mailx or sendmail command

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

RE: mailx or sendmail command

uuencode file.txt file.txt | mailx -s "attached is file"

RE: mailx or sendmail command

this will not work with (our?) Exchange 2002 SP3

Best Regards, Franz
UNIX System Manager from Munich, Germany

RE: mailx or sendmail command


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.




RE: mailx or sendmail command

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

RE: mailx or sendmail command


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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

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!


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