linux下使用uuencode/mutt发送带附件的邮件(转)

http://www.2hei.net/mt/2009/07/linux-uuencode-mutt-sendmail.html

linux下使用uuencode/mutt发送带附件的邮件:

前提,sendmail服务配置好且正常工作:

设置附件大小:
cat /etc/mail/sendmail.cf
O MaxMessageSize=10485760   #10m

方法一: 使用uuencode
下载地址:
http://rpm.pbone.net/index.php3/stat/4/idpl/8081358/com/sharutils-4.6.1-2.x86_64.rpm.html
根据内核版本找到相应的rpm包
rpm -ivh sharutils-4.6.1-2.x86_64.rpm
使用:
uuencode openssl-0.9.8b-allow_lib64-2.patch openssl-0.9.8b-allow_lib64-2.patch | mail -s " Attachement test"  2hei@2hei.net

方法二:使用mutt
http://www.mutt.org
mutt是linux下的email 客户端软件,小巧灵活
编译:
./configure --prefix=/home/mutt

用法:
/home/mutt/bin/mutt -s "test sunbject" -a test.txt 2hei@2hei.net < mailconn.txt

修改发送者:
系统全局设置/etc/Muttrc,如果使用某个系统用户,可以在~/.muttrc中设置。
vi ~$HOME/.muttrc

my_hdr From:  **统计员


#!/bin/bash
#
# Script. mailusemutt.sh
# Use   : sendmail with attachment
# Date  : 2009/07/15  by 2hei
# Usage: mail.sh [attachmentfile]
# Exp  : ./mail.sh test.txt
# MSG : if no attachment then this shell can sendmail without attachment!
# Requires: You need installed mutt. URL:http://www.mutt.org
# Mail-Content: test.txt

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
LANG=zh_CN.gbk
export PATH LANG

Mail_Date=`date +%Y%m%d "-d 1 days ago"`
Mutt_Path='/home/mutt/bin'
Shell_Path='/home/shell/mutt_mail'
Subject='中文主题测试 : $Mail_Date'
qSubj='"'$Subject'"'
Attachment='-a $1'
Recv_Mail_list='2hei@2hei.net'
CC_Mail_list='others@test.com'

if [ $# -ne 1 ];then
  echo "you send a mail without attachment!"
  echo "usage: mail.sh [attachement]"
  eval $Mutt_Path/mutt -s $qSubj "$Recv_Mail_list" -c "$CC_Mail_list" < test.txt
else
  if [ ! -f $1 ];then
    echo "You attachment : $1 is not a file!"
  else
    eval $Mutt_Path/mutt -s $qSubj $Attachment "$Recv_Mail_list" -c "$CC_Mail_list" < test.txt
  fi
fi

备注:
mutt 功能说明:E-mail管理程序。
语  法:mutt [-hnpRvxz][-a][-b][-c][-f] [-F][-H][-i][-m][-s][邮件地址]

补充说明:mutt是一个文字模式的邮件管理程序,提供了全屏幕的操作界面。

参  数:
-a 在邮件中加上附加文件。
-b 指定密件副本的收信人地址。
-c 指定副本的收信人地址。
-f 指定要载入的邮件文件。
-F 指定mutt程序的设置文件,而不读取预设的.muttrc文件。
-h 显示帮助。
-H 将指定的邮件草稿送出。
-i 将指定文件插入邮件内文中。
-m 指定预设的邮件信箱类型。
-n 不要去读取程序培植文件(/etc/Muttrc)。
-p 在mutt中编辑完邮件后,而不想将邮件立即送出,可将该邮件暂缓寄出。
-R 以只读的方式开启邮件文件。
-s 指定邮件的主题。
-v 显示mutt的版本信息以及当初编译此文件时所给予的参数。
-x 模拟mailx的编辑方式。
-z 与-f参数一并使用时,若邮件文件中没有邮件即不启动mutt

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/110321/viewspace-617496/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/110321/viewspace-617496/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值