命令行下面发送邮件比较简单,恐怕都会使用。
$ 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: