Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mailx or sendmail command

Status
Not open for further replies.

yy2

MIS
May 3, 2006
10
US
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.

 
I am using a script, wich I found in
substitute sender, receptient, servername, yourdomain

Code:
#!/sbin/sh

#
# cut some blahblah
#

func_send_email()
{

(
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
 
uuencode file.txt file.txt | mailx -s "attached is file" you@mail.com
 
this will not work with (our?) Exchange 2002 SP3

Best Regards, Franz
--
UNIX System Manager from Munich, Germany
 
Franz,

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.

Mike

Thanks,

mcolford
 
hmmm, I have seen problems with attachments but not with mailbodies.
Are you sure you have the same
boundary="PAA08673.1018277622/servername.yourdomain.com"
everywhere? Please replace servername and domainname by the values used by your senderhost

Best Regards, Franz
--
UNIX System Manager from Munich, Germany
 
Try

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

make sure you have a relay set in sendmail.cf

DSyourexchangeserver.com

Mike

"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."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top