Postfix + DSPAM

Notice: Undefined variable: recipient in /srv/www/lbr.com.br/site/modules/assunto/assunto.php(98) : eval()'d code on line 185

Notice: Undefined variable: sender in /srv/www/lbr.com.br/site/modules/assunto/assunto.php(98) : eval()'d code on line 185

Notice: Undefined variable: recipient in /srv/www/lbr.com.br/site/modules/assunto/assunto.php(98) : eval()'d code on line 185

Notice: Undefined variable: nexthop in /srv/www/lbr.com.br/site/modules/assunto/assunto.php(98) : eval()'d code on line 188

Notice: Undefined variable: sender in /srv/www/lbr.com.br/site/modules/assunto/assunto.php(98) : eval()'d code on line 188
  1. Criar o usuário dspam.
    useradd -r -d /var/lib/dspam  dspam
    
  2. Instalar os pacotes:
    apache
    dspam-backend-pgsql
    dspam-cgi
    postfix-pcre
    
  3. Alterar a senha do usuário dspamadmin
    htpasswd /usr/share/dspam/cgi-bin/.htpasswd dspamadmin
    
  4. Adicionar o usuário apache ao grupo mail.
    usermod -G mail apache
    
  5. Configurar o dspam
    dspam_admin ch pref default trainingMode TEFT
    dspam_admin ch pref default spamAction quarantine
    dspam_admin ch pref default enableWhitelist on
    dspam_admin ch pref default showFactors on
    
  6. Configurar o postgresql.
    • Instalar o pacote:
      postgresql-server
      postgresql-plpgsql
      
    • Iniciar o serviço postgresql e configurá-lo para iniciar automaticamente:
      service postgresql start
      chkconfig postgresql on
    • Executar os comandos:
      createuser -U postgres --no-createdb --no-adduser --no-createrole dspam
      createdb   -U postgres dspam --owner dspam
      psql       -U postgres dspam < /usr/share/dspam-pgsql/virtual_users.sql
      psql       -U postgres dspam < /usr/share/dspam-pgsql/pgsql_objects.sql
      psql       -U postgres dspam
      dspam=# alter user dspam with password 'xxx';
      ALTER TABLE dspam_preferences OWNER TO dspam;
      ALTER TABLE dspam_signature_data OWNER TO dspam;
      ALTER TABLE dspam_stats OWNER TO dspam;
      ALTER TABLE dspam_token_data OWNER TO dspam;
      ALTER TABLE dspam_virtual_uids OWNER TO dspam;
      ALTER TABLE dspam_virtual_uids_seq OWNER TO dspam;
      
  7. Configurado o dspam. Alterar o arquivo /etc/dspam.conf:
    Home /var/lib/dspam
    
    StorageDriver /usr/lib/dspam/libpgsql_drv.so
    
    TrustedDeliveryAgent "/usr/sbin/sendmail"
    
    DeliveryHost        127.0.0.1
    DeliveryPort        10025
    DeliveryIdent       localhost
    DeliveryProto       SMTP
    
    OnFail error
    
    Trust root
    Trust mail
    Trust mailnull 
    Trust smmsp
    Trust daemon
    Trust dspam
    Trust apache
    Trust postfix
    
    TrainingMode teft
    
    TestConditionalTraining on
    
    Feature chained
    Feature whitelist
    
    Algorithm graham burton
    
    PValue graham
    
    Preference "spamAction=quarantine"
    Preference "signatureLocation=message"  # 'message' or 'headers'
    Preference "showFactors=on"
    
    AllowOverride trainingMode
    AllowOverride spamAction spamSubject
    AllowOverride statisticalSedation
    AllowOverride enableBNR
    AllowOverride enableWhitelist
    AllowOverride signatureLocation
    AllowOverride showFactors
    AllowOverride optIn optOut
    AllowOverride whitelistThreshold
    AllowOverride localstore
    
    PgSQLServer     127.0.0.1
    PgSQLPort       5432
    PgSQLUser       dspam
    PgSQLPass       p0o9i8u7
    PgSQLDb         dspam
    
    PgSQLUIDInSignature     on 
    
    HashRecMax              98317
    
    HashAutoExtend          on  
    
    HashMaxExtents          0
    
    HashExtentSize          49157
    
    HashMaxSeek             100
    
    HashConnectionCache     10
    
    Notifications   off
    
    PurgeSignatures 14          # Stale signatures
    PurgeNeutral    90          # Tokens with neutralish probabilities
    PurgeUnused     90          # Unused tokens
    PurgeHapaxes    30          # Tokens with less than 5 hits (hapaxes)
    PurgeHits1S     15          # Tokens with only 1 spam hit
    PurgeHits1I     15          # Tokens with only 1 innocent hit
    
    LocalMX 127.0.0.1
    
    SystemLog on
    UserLog   on
    
    Opt out
    
    ParseToHeaders on
    ChangeModeOnParse no
    ChangeUserOnParse no
    
    ClamAVPort      3310
    ClamAVHost      127.0.0.1
    ClamAVResponse reject
    
    ServerPID "/var/run/dspam/dspam.pid"
    
    ServerMode auto
    
    ServerParameters        "--deliver=innocent"
    ServerIdent             "localhost.localdomain"
    
    ServerDomainSocketPath "/var/spool/postfix/tmp/dspam.sock"
    
    ClientHost "/var/spool/postfix/tmp/dspam.sock"
    
    ProcessorBias on
    
  8. Configurar permissões para o dspam:
    find /var/lib/dspam -type d -exec chmod 770 {} \;
    find /var/lib/dspam -type d -exec chmod g+s {} \;
    chown -R dspam:mail /var/lib/dspam/
    
  9. Editar o arquivo main.cf

    Na última linha da configuração do campo smtp_client_restrictions, adicionar a seguinte linha:

    check_client_access pcre:/etc/postfix/dspam_filter_access
  10. Adicionar as seguintes linhas ao final do arquivo /etc/postfix/master.cf
    127.0.0.1:10025 inet    n       -       y       -       -       smtpd
       -o smtpd_authorized_xforward_hosts=127.0.0.0/8
       -o smtpd_client_restrictions=
       -o smtpd_helo_restrictions=
       -o smtpd_sender_restrictions=
       -o smtpd_recipient_restrictions=permit_mynetworks,reject
       -o mynetworks=127.0.0.0/8
       -o receive_override_options=no_unknown_recipient_checks
    dspam           unix    -       n       n       -       2     pipe
      flags=Ru user=dspam argv=/usr/bin/dspam --deliver=innocent --user  -i -f  -- 
    
    dspam-retrain   unix    -       n       n       -       2     pipe
      flags=Ru user=dspam argv=/usr/bin/dspam --client --source=error --class= --user 
    retry	unix	-	-	y	-	-	error
  11. Iniciar o serviço clamd e configurá-lo para iniciar automaticamente:
    service clamd start
    chkconfig clamd on
  12. Reiniciar o postfix:
    service postfix restart
IP
3.236.51.151