Log In

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!
  • Students Click Here

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

Students Click Here


mailx or sendmail command

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 http://itrc.hp.com

substitute sender, receptient, servername, yourdomain



# cut some blahblah


echo "From: sender@yourdomain.com"
echo "To: reciptient@yourdomain.com"
echo "MIME-Version: 1.0"
echo "Content-Type: multipart/mixed;"
echo ' boundary="PAA08673.1018277622/servername.yourdomain.com"'
echo "Subject: set the subject here"
echo "--PAA08673.1018277622/servername.yourdomain.com"
echo "Content-Type: text/plain"
cat < $1
echo "--PAA08673.1018277622/servername.yourdomain.com"
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" you@mail.com

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" mail@mail.com

make sure you have a relay set in sendmail.cf



"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