Answers:
我在开发箱中通过完全禁用sendmail,然后让一个简单的perl脚本侦听SMTP端口并将电子邮件转储到目录中来完成此操作。我确定可以使用sendmail配置,但是perl脚本要容易得多。精简如下:
#!/usr/bin/perl -w
use Net::SMTP::Server;
use Net::SMTP::Server::Client;
$server = new Net::SMTP::Server || die("$!\n");
while($conn = $server->accept()) {
my $client = new Net::SMTP::Server::Client($conn) ||
die("Unable to handle client connection: $!\n");
$client->process || next;
# Here's where you can write it out or just dump it. Set $filename to
# where you want to write it
open(MAIL,"> $filename") || die "$filename: $1";
print(MAIL "$client->{MSG}\n");
close(MAIL);
}