LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
楼主: BnuFancy

mail命令可以发送附件吗?

[复制链接]
发表于 2005-1-13 10:22:54 | 显示全部楼层
手册里面没有提到有-a这个参数啊,楼上的实验过了?

我一直用的是email或sendemail.pl来从命令行发邮件
发表于 2005-1-13 10:56:38 | 显示全部楼层
怎么没有?
NAIL(1)                   User Commands                   NAIL(1)

NAME
       nail - send and receive Internet mail

SYNOPSIS
       nail [-BDdFintv~] [-s subject] [-a attachment ] [-c cc-
              addr] [-b bcc-addr] [-r from-addr] [-h hops]
              [-A account] to-addr . . .
       nail [-BDdeHiInNv~] [-T name] [-A account] -f [name]
       nail [-BDdeinNv~] [-A account] [-u user]

       ~@ [filename . . . ]
              With   no  arguments,  edit  the  attachment  list.
              First, the user can edit  all  existing  attachment
              data.   If an attachment's file name is left empty,
              that attachment is deleted from the list.  When the
              end  of  the  attachment list is reached, nail will
              ask for further attachments, until  an  empty  file
              name  is  given.   If filename arguments are speci-
              fied, all of them are appended to the  end  of  the
              attachment  list.   Filenames  which  contain white
              space can only be specified with the  first  method
              (no filename arguments).
发表于 2005-1-13 11:13:05 | 显示全部楼层
这个是nail呀,我的系统里没有这个,我用的是rh9,
我的系统man mail的确没有发附件的说明
发表于 2005-1-13 12:17:09 | 显示全部楼层
大概redhat上的mail是mailx吧,我看了man了,在命令行上好像是没什么办法,但可以在邮件中试试命令"~r",在它后面加文件名:
   ~r filename
          reads  in the contents of the specified file and adds that text
          at this point in the message.

另外,我的slackware上装的是nail,建议去nail.sourceforge.net上看看.
发表于 2005-1-13 13:50:15 | 显示全部楼层
命令"~r",在它后面加文件名:
~r filename
reads in the contents of the specified file and adds that text
at this point in the message.


这样是不行的,邮件内容还可以,但是附件的话会是乱码。
发表于 2005-1-13 14:09:45 | 显示全部楼层
那就算了,还是装nail吧,反正是一回事.我一直用的好好的,这是我的配置.mailrc
set charset=gb2312
set ttycharset=gb2312
set pipe-text/html="lynx -dump -force_html /dev/stdin"
set smtp=smtp.mail.yahoo.com
set smtp-auth=login
set smtp-auth-user=******
set smtp-auth-password=******

我是直接用smtp发信,用fetchmail+procmail收信,不用什么sendmail.
这是.fetchmailrc
File Edit Options Buffers Tools Help
set daemon 600

defaults
mda "/usr/bin/procmail -f %F"

poll "pop.mail.yahoo.com"
protocol pop3
username "******"
password "******"
nokeep
发表于 2005-4-1 10:25:46 | 显示全部楼层
mail也是个外壳程序吗?要调用别的程序发送?
回复 支持 反对

使用道具 举报

发表于 2005-4-6 11:29:16 | 显示全部楼层
请问使用nail的高手,nail能不能非交互使用?

比如我用这个命令:

nail -s "from nail" -a iptables-tutorial.html.tgz -r "sdf@sldfjlas.com" -q jifang.txt   win2linux@163.com

发送内容为jifang.txt,附件为iptables-tutorial.html.tgz的邮件,nail会显示jifang.txt的内容
然后我最后还要输入一个 "." 和一个回车或者按ctrl+D他才开始发送,我想直接一条命令下去就自动发送,不要人机交互过程,应该怎么做?谢谢!
回复 支持 反对

使用道具 举报

发表于 2005-4-6 19:45:12 | 显示全部楼层
uuencode amavisd-new-2.2.1.tar.gz ttfm-1.0-6.i386.rpm | mail a9020

忘记说了。我在mailserver上用的。
实际我只收到了ttfm那个附件。。。
回复 支持 反对

使用道具 举报

发表于 2005-4-7 09:37:33 | 显示全部楼层
Post by gucuiwen
请问使用nail的高手,nail能不能非交互使用?

比如我用这个命令:

nail -s "from nail" -a iptables-tutorial.html.tgz -r "sdf@sldfjlas.com" -q jifang.txt   win2linux@163.com

发送内容为jifang.txt,附件为iptables-tutorial.html.tgz的邮件,nail会显示jifang.txt的内容
然后我最后还要输入一个 "." 和一个回车或者按ctrl+D他才开始发送,我想直接一条命令下去就自动发送,不要人机交互过程,应该怎么做?谢谢!


通过试验,我这个问题已经自己解决.用输入重定向符 "<" 就解决了不用交互发邮件的问题.
这样就可以写在bash脚本里实现自动发邮件.

for i in `seq 1 10000` ; do

  nail -s "from nail" -a iptables-tutorial.html.tgz -r "sdf@sldfjlas.com" badgay@some.com  ;
  sleep 0.5;
done;

我用以上命令给那些给我发垃圾邮件的家伙连续发了10000封警告邮件.因为自己电脑上有SMTP服务器,因此实现起来很容易,之所以要sleep 0.5 ,是因为一下子压10000封邮件到自己电脑上的qmail服务器,自己电脑将受不了,很多邮件因为超时而不能发.经试验,间隔一小段时间,比如0.5妙,发一封效果最好.大家可以用这种方法来对付那些讨厌的家伙.可以想像他打开邮箱看到有几万封邮件的时候是什么表情 :cool:
回复 支持 反对

使用道具 举报

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

本版积分规则

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