命令行发送有附件的邮件

命令行下面发送邮件比较简单,恐怕都会使用。

$ echo "hello .. " | mail -s subject xxx@abc.com
$ cat /path/to/file | mail -s subject xxx@abc.com
$ mail -s subject xxx@abc.com << EOF
hi
the end..
EOF

上面这些方法都可以发送邮件。还有一种方法。

$ cat a.txt
Subject: test
From: xxx@abc.com
To: xxx@abc.com
 
hi
sdfsdfsdf
the end.
$ cat a.txt | sendmail -t

这样可以把邮件头信息写到文件里面的,你也可以用 php,perl 来打印类似的信息给 sendmail -t ,让他来发。

那么如果有附件应该怎么办?可以使用 uuencode。

$ uuencode a.txt a.txt | mail -s test xxx@abc.com
$ (cat a.txt; uuencode b.txt b.txt; cat c.txt) |sendmail -t

应该说的很明白了吧?

Related posts:

  1. caphit qmail 配置
  2. 自动贴星运的脚本
  3. 在linux重新启动下如何设置oracle服务自动开启
  4. 邮件如何从A点到达B点zz
  5. Howto Qmail with spamassassin

Post a Comment

Your email is never shared.