unix命令行如何发送附件

王朝system·作者佚名  2008-05-18
窄屏简体版  字體: |||超大  

The script show how to send mail with attachment in UNIX.

The attchment is an ascii file.(Binary file should have another tool to convert it) .

#!/bin/ksh

#mail infomation

filename=test.csv

subject="test email with attachment"

body="This is a test mail."

MAILFROM=rollingpig@163.com

MAILTO=serol_luo@gmail.com

#boundary is random string to seperate parts of mail

boundary=396d983d6b89a

#temporay file,to store mail content

tmpfile=/tmp/a.tmp

cat > $tmpfile <<EOF

Return-Path: <$MAILFROM>

From:<$MAILFROM>

To:<$MAILTO>

Content-type: multipart/mixed; boundary="$boundary"

Subject: $subject

--396d983d6b89a

Content-type: text/plain; charset=iso-8859-1

Content-transfer-encoding: 8bit

$body

--$boundary

Content-disposition: inline; filename=$filename

EOF

cat $filename >>$tmpfile

echo --$boundary-- >> $tmpfile

mail $MAILTO < $tmpfile

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航