Think before you speak, read before you think.

用Mutt发送带附件的邮件

请提前设置好MTA(mail transfer agent),例如:

debian默认的MTA为exim4的设置为http://jpuyy.com/2011/08/debian-exim4.html

mutt – The Mutt Mail User Agent

示例:

/usr/bin/mutt -s “the mp3 push” [email protected] -a /root/getvoa/latestvoa.mp3 < /dev/null

最有用的还是这个 -a 附件发送,因为用mail和uuencode发送mp3都不理想

用/dev/null意思是不输入正文,如果没有 </dev/null 则会自动调用nano

介面简单而实用

我的目的是每天自动把某网页更新的voa听力发送到我的邮箱内

#!/bin/bash
#for use:get voa mp3 every day
#author: 2011-08-28 jpuyy.com
#version: A
yes | rm `cat latestvoa`
LANG=C
theday=`date ‘+%A’`
urlone=http://www.51voa.com/VOA_Special_English/VOA_News_$theday.html
urltwo=`/usr/bin/curl $urlone | grep Player`
urltwo=${urltwo#*\”}
urlthree=http://down.51voa.com${urltwo%%\”*}
filename=${urlthree##*\/}
echo $filename > latestvoa
wget $urlthree
/usr/bin/mutt -s “$theday mp3 push” [email protected] -a /root/getvoa/$filename < echo $filename

保存为 getvoa.sh 这样每天的18点运行脚本

0 18 * * * /root/getvoa/getvoa.sh

 


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *