QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1928|回复: 8

请问如何在shell里面发email?

[复制链接]
发表于 2005-12-6 09:07:39 | 显示全部楼层 |阅读模式
google一下, 发现很多方法都不能满足要求, 希望能有经验者指条明道.

要求为:
1)支持SMTP的认证. 可以设置SMTP host, port, account, password.
2)支持附件.
3)如果能支持subject和信体的encoding更好.
发表于 2005-12-6 11:37:53 | 显示全部楼层
telnet mailserver 25
回复

使用道具 举报

 楼主| 发表于 2005-12-6 11:58:22 | 显示全部楼层
开什么玩笑.
回复

使用道具 举报

发表于 2005-12-6 12:11:56 | 显示全部楼层
mutt
回复

使用道具 举报

发表于 2005-12-15 14:57:26 | 显示全部楼层
不知道 关注中...
回复

使用道具 举报

发表于 2005-12-21 15:54:41 | 显示全部楼层
好麻烦哦
回复

使用道具 举报

发表于 2005-12-21 15:59:00 | 显示全部楼层
不知道,从没有用过!!...........高手指教.......
回复

使用道具 举报

发表于 2005-12-21 16:44:06 | 显示全部楼层
自己看下面的shell脚本吧,不多说了。
[code:1]
#!/bin/sh

function echo_help(){
echo "Usage:"
echo "sh mailto.sh -to mailaddr -file messagefilename [-from frommailaddr] [-subject mailsubject] [-fname showname] [-tname toshowname]"
}

email="[email protected]"
emailname="Test Mail"
messagebody="tmp.tmp"
from="[email protected]"
fromname="MailReport"
subject="Mail Report"

until [ $# -eq 0 ]
do
tmpV=$1

if [ $tmpV = "-from" ] ; then
shift
tmpV=$1
from=$tmpV
elif [ $tmpV = "-to" ] ; then
shift
tmpV=$1
email=$tmpV
elif [ $tmpV = "-subject" ] ; then
shift
tmpV=$1
subject=$tmpV
elif [ $tmpV = "-file" ] ; then
shift
tmpV=$1
messagebody=$tmpV
elif [ $tmpV = "-fname" ] ; then
shift
tmpV=$1
fromname=$tmpV
elif [ $tmpV = "-tname" ] ; then
shift
tmpV=$1
emailname=$tmpV
elif [ $tmpV = "--help" -o $tmpV = "-h" ] ; then
echo_help
exit 1
fi

shift
done

if ! test -f ${messagebody} ; then
echo "${messagebody} not exists!"
echo_help
exit 2
fi

echo "begin send..."

echo -e "To: \"${emailname}\" <${email}>
From: \"${fromname}\" <${from}>
Subject: ${subject}

`cat ${messagebody}`" | /usr/sbin/sendmail -t

echo "send OK."

[/code:1]
回复

使用道具 举报

 楼主| 发表于 2005-12-27 12:38:59 | 显示全部楼层
先谢谢您的代码, 不过上面的代码不符合我提的三个要求.
1)在shell中用了本机的sendmail来作MTA,  不是使用其他的SMTP server的. 当然也就不能设置"SMTP host, port, account, password."

2)没有支持附件(应该Base64压码吧?)

3)没有对subject encoding.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-10-1 21:17 , Processed in 0.064925 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表