2009-04-16 125 views
5

我有一个postfix电子邮件服务器,并且存在我想调试的问题。 如何配置它将每封电子邮件的副本发送到我的电子邮件(除了将电子邮件发送给其预期的收件人)。后缀:将每封电子邮件的副本发送到给定的电子邮件地址

+0

http://serverfault.com/questions/407302/how-can-i-configure-postfix-to-retain-copies-of-all-email-sent-through-it有更好的答案,因为它使用功能由postfix提供。 – 2015-07-16 05:20:20

回答

8

最近,我得到这个工作,所以虽然我会分享:

发送所有发出的邮件与后缀和Cyrus IMAP发送文件夹。

摘要

制作后缀发送所有外发邮件的BCC拷贝到一个特殊的“已发送” 邮件帐户。在此特殊帐户上使用sieve将所有电子邮件 重定向到与该帐户关联的已发送文件夹。

  1. 创建发送

    最简单的方法电子邮件用户帐户做,这是创建一个新的UNIX帐户发送, 外壳设置为/ bin/false,以防止任何人能够登录 在:

    host$ sudo useradd sent 
    host$ sudo chsh -s /bin/false sent 
    
  2. 设置IMAP为发送的用户

    使用cyradm我们创建了一个NE w ^邮箱(即用户),并赋予该用户追加 访问所有我们的IMAP“已发送”的文件夹:

    host$ $ cyradm -user cyrus localhost 
    Password: <enter you cyrus user admin password here> 
    localhost> createmailbox user.sent 
    localhost> setaclmailbox user.%.Sent sent append 
    Setting ACL on user.userx.Sent...OK. 
    Setting ACL on user.usery.Sent...OK. 
    . . . 
    Setting ACL on user.userz.Sent...OK. 
    localhost> exit 
    
  3. 为发送帐户

    这个脚本会重定向所有传入电子邮件创建一个筛子脚本到已发送的帐户,发送到发件人收件箱中的 已发送文件夹。

    我的脚本称为sent.sieve,看起来是这样的:

    # Sieve script for sent. If outgoing email is bcc'ed to this account, 
    # this sieve script will redirect it to the sender's Sent folder 
    require ["fileinto"]; 
    
    if address :is :localpart "From" "userx" { 
        fileinto "user.userx.Sent"; 
    } 
    elsif address :is :localpart "From" "usery" { 
        fileinto "user.usery.Sent"; 
    } 
    elsif address :is :localpart "From" "userz" { 
        fileinto "user.userz.Sent"; 
    } 
    

    你将需要把一个条目为每个用户(用户X,usery,在本例中 userz以上)。我一直无法 找到一个更好的方式来做到这一点。建议是欢迎 [email protected]

    安装筛这样的脚本:

    host$ sieveshell localhost -user=sent -a=cyrus 
    Password: <enter you cyrus user admin password here> 
    > put sent.sieve 
    > activate sent.sieve 
    > quit 
    
  4. 为Postfix设置

    的BCC映射在后缀目录(/等/后缀上Debian的)创建一个名为 bcc_map文件看起来像这样:

    # copy all locally sent mail to the sent account 
    @yourdomain.com  [email protected] 
    

    编译成一个后缀哈希此文件使用:

    host$ sudo postmap bcc_map 
    

    将以下行添加到postfix main。CF配置文件:

    sender_bcc_maps = hash:/etc/postfix/bcc_map 
    

    而且使后缀重新加载其配置:

    主机$ sudo的/etc/init.d/postfix重装

  5. 测试和调试

    发送一些电子邮件和检查它是否被复制到已发送的文件夹中。

    如果遇到问题,您应该检查cyrus和postfix日志 (所有日志都记录在我的debian主机上的/var/log/syslog)。错别字和错误的 访问权限通常会导致一些线索被发送到 日志。

2

只需添加在/etc/postfix/main.cf中[email protected]并重新启动服务器后缀。我在底部添加了这一行。

它真的好像在工作。关于always_bcc的更多信息here

请不要忘记先备份这个文件。

相关问题