Create a full mail server (postfix) on FreeBSD

xiaoxiao2021-03-06  72

Part 1: Installing the Mail Server: Postfix VM-POP3D OpenWebmail

Welcome everyone to post this article, but to keep the following copyright information:

Author: llzqq

Source: www.chinaunix.net

Contact: llzqq@126.com

The following installation is completed on the FreeBSD 5.2.1 system.

1. Update ports

# cvsup -gl 2 -h cvsup.freebsdchina.org / usr / share / example / cvsup / ports-suppile

2. Install the OpenSSL APACHE server

# CD / USR / PORTS / Security / OpenSSL

# make install

# make clean

# cd / usr / ports / www / apache2

# make install

# make clean

# vi /etc/rc.conf

Apache2_enable = "yes"

3. Install OpenWebmail

# CD / USR / PORTS / MAIL / OpenWebmail /

# make with_quota = yes install

# make clean

4. Install the postfix, answer questions with Yes during the installation process

# cd / usr / ports / mail / postfix /

# make install

# make clean

# vi /etc/rc.conf

In order to start Postfix to join:

Sendmail_enable = "yes"

Sendmail_flags = "- bd"

Sendmail_PIDFILE = "/ var / spool / postfix / pid / master.pid"

Sendmail_outbound_enable = "no"

Sendmail_submit_enable = "no"

5. Install VM-POP3D

# CD / USR / PORTS / MAIL / VM-POP3D

# make install

# make clean

6. Configure postfix

# vi /usr/local/etc/postfix/main.cf

Add to:

MyHostName = NERO.3322.org

Mydomain = NERO.3322.org

Virtual_Alias_maps = hash: / usr / local / etc / postfix / virtual

Alias_maps = hash: / usr / local / etc / postfix / aliases

DEFAULT_PRIVS = NoBody

Allow_mail_to_commands = alias, forward, include

ALLOW_MAIL_TO_FILES = Alias, Forward, Include

Below I join a virtual domain of Nero.3322.org and add a user LLZQQ

# vi / usr / local / etc / postfix / virtual

Add to:

Nero.3322.org Anything / / Use [TAB]

Llzqq@nero.3322.org

Llzqq.nero.3322.org / / [tab]

Execute the following command to generate virtual.db:

# CD / usr / local / etc / postfix /

# Postmap Virtual

# vi / usr / local / etc / postfix / aliases

Add to:

Llzqq.nero.3322.org:/var/spool/virtual/nero.3322.org/llzqq Execute the following command to generate aliases.db:

# cd / usr / local / etc / postfix

# Postalias Aliases

7. Configure VM-POP3D to turn it automatically

# cd /usr/local/etc/rc.d

# mv vm-pop3d.sh.sample VM-POP3D.SH

Configure OpenWebmail to support the Nero.3322.org domain, create the following files:

# vi /usr/local/www/cgi-bin/openwebmail/etc/sites.conf/nero.3322.org

=========================== Nero.3322.org ================================================================================================================================================================================================================ =====

Auth_module auth_vdomain.pl

Auth_withdomain YES

MailspoolDir /var/spool/virtual/neero.3322.org

Use_syshomedir no

Use_homedirspools no

Enable_AUTOREPLY NO

Enable_setForward No

Enable_vdomain YES

VDOMAIN_ADMLIST LLZQQ // Sets this domain administrator

VDOMAIN_MAXUSER 500

VDOMAIN_VMPOP3_PWDPATH / USR / LOCAL / ETC / VIRTUAL

vDomain_vmpop3_pwdname passwd

VDOMAIN_VMPOP3_MAILPATH / VAR / SPOOL / VIRTUAL

VDOMAIN_POSTFIX_ALIASES / USR / local / etc / postfix / aliases

VDOMAIN_POSTFIX_VIRTUAL / USR / LOCAL / ETC / Postfix / Virtual

VDOMAIN_POSTFIX_POSTALIAS / USR / LOCAL / SBIN / POSTALIAS

VDOMAIN_POSTFIX_POSTMAP / USR / local / sbin / postmap

# Quota Settings section

Quota_module quota_du.pl

Quota_limit 52400 / / Defines the email size

Quota_threshold 85

Delmail_ifquotahit no

Delfile_ifquotahit no

=========================== Nero.3322.org ================================================================================================================================================================================================================ =====

# mkdir -p /var/spool/virtual/nero.3322.org

# chown nobody /var/spool/virtual/nero.3322.org

# chgrp mail /var/spool/virtual/nero.3322.org# mkdir -p /usr/local/etc/virtual/nero.3322.org

# Touch /usr/local/etc/virtual/nero.3322.org/passwd

# chmod 644 /usr/local/etc/virtual/nero.3322.org/passwd

# htpasswd /usr/local/etc/virtual/nero.3322.org/passwd llzqq

# chmod 755 / usr / local / www / cgi-bin / openwebmail / etc / users

# sync

# reboot

8. Finally, log in to OpenWebmail via browser

Http://nero.3322.org/cgi-bin/openwebmail/openwebmail.pl

Part II: Anti-virus, Spam: CLAMAV AMAVISD-New SPAM

Welcome everyone to post this article, but to keep the following copyright information:

Author: llzqq

Source: www.chinaunix.net

Contact: llzqq@126.com

1.0 Installing Clamav:

# CD / USR / PORTS / Security / CLAMAV

# make install

# make clean

# vi /usr/local/etc/clamav.conf

================================ ===================== ============

# Comment Or Remove The Line Below.

# EXample

Logfile /var/log/clamav/clamd.log

LogfileMaxSize 1M

Logtime

Logverbose

Pidfile /var/run/clamav/clamd.pid

DataDirectory / usr / local / share / clamav

Localsocket / TMP / CLAMD

StreamMaxLength 10M

Maxthreads 10

MaxDirectoryRecursion 15

User Clamav

Scanmail

Scanarchive

Scanrar

ArchiveMaxFileSize 10M

ArchiveMaxRecursion 5

ArchiveMaxFiles 1000

Clamukoscanonopen

ClamukoscanonClose

Clamukoscanonexec

ClamukoinCludePath / VAR / Spool / Virtual

ClamukomaxFileSize 6M

Clamukoscanarchive

================================ ===================== ============ 1.1 update virus database

# /usr/local/etc/rc.d/clamav-freshclam.sh Start

2.0 Install Amavisd-New

# CD / USR / PORTS / Security / AMAVISD-NEW

# make install

# make clean

# cd / usr / local / etc

# mv Amavisd.conf-dist Amavisd.conf

# vi amavisd.conf

============================== amavisd.conf ================= ==============

$ MyHome = '/ var / amavis'; # (default is' / var / amavis))

$ mydomain = 'Nero.3322.org'; # (no useful default)

$ daemon_user = 'vscan'; # (No Default; Customary: vscan or amavis)

$ daemon_group = 'vscan'; # (no default; customary: vscan or amavis)

$ log_level = 0;

$ SA_SPAM_SUBJECT_TAG = '*** SPAM ***'

$ virus_admin = "root / @ $ mydomain";

$ spam_admin = "llzqq / @ $ mydomain";

$ mailfrom_notify_admin = "llzqq / @ $ mydomain";

$ mailfrom_notify_recip = "llzqq / @ $ mydomain";

$ MailFrom_notify_spamadmin = "llzqq / @ $ mydomain";

$ inet_socket_bind = '127.0.0.1';

$ forward_method = 'SMTP: 127.0.0.1: 10025';

$ notify_method = $ forward_method;

$ inet_socket_port = 10024;

$ MAX_SERVERS = 2;

['CLAM ANTIVIRUS-CLAMD',

/ & ask_daemon, ["Contscan {} / n", '/ tmp / clamd'], qr // bok $ /, qr // bfound $ /,

QR /1.* ?: (?! infected archive) (. *) Found $ /],

============================== amavisd.conf ================= ==============

2.1 To launch Clamav and Amavisd-New to configure /etc/rc.conf

# vi /etc/rc.conf

Spamd_enable = "yes"

Amavisd_enable = "YES

Clamav_clamd_enable = "yes"

3.0 Since Spamassassin is installed together to configure it together when installing AMAVISD-NEW

3.1 Creating a filtering rule:

# cd / usr / local / etc / mail / spamassassin

# env lang = c vi local.cf

=============================== ==================== ================

# Spamassassin config file for version x.xx

#enerated by

Http://www.yrex.com/spam/spamconfig.php

(Version 1.01)

# How Many Hits Before A Message IS Considered Spam.

Required_hits 4.0

# WHETHER TO CHANGE The Subject Of Suspected SPAM

ReWrite_Subject 1

# Text to prepend to subject if shutrite_subject is used

SUBJECT_TAG ***** SPAM *****

# Encapsulate spam in an attachment

Report_safe 1

# UE TERSE VERSION OF THE SPAM REPORT

Use_Terse_Report 0

# Enable the bayes system

Use_bayes 1

# Enable Bayes Auto-Learning

Auto_learn 1

# Enable or disable network checks

SKIP_RBL_CHECKS 1

Use_razor2 0

USE_DCC 0

Uses_pyzor 0

# Mail Using Languages ​​Used in these Country Codes Will Not Be Marked # as being Possibly spam in a foreign language.

# - chinese english

OK_LANGUAGES EN EN

# Mail Using Locales Used in There Country Codes Will Not Be Marked

# as being possibly spam in a foreign language.

Ok_locales en zh

Score Subj_Full_OF_8BITS 2

Score no_real_name 4.0

=============================== ==================== ================

3.2 Download a new spam address list file

# cd / usr / local / share / spamassassin

# fetch

http://anti-spam.org.cn/rules/sa/55_diy_score.cf

4.0 Configuring POSFIX and adds some of the following in his profile

# vi /usr/local/etc/postfix/master.cf

--------------------- Master.cf ---------------------

SMTP-AMAVIS UNIX - - N - 2 SMTP

-o SMTP_DATA_DONE_TIMEOUT = 1200

-o disable_dns_lookups = yes

127.0.0.1:10025 INET N - N - - SMTPD

-o content_filter =

-o local_recipient_maps =

-o relay_recipient_maps =

-o SMTPD_RESTRICTION_CLASSES =

-o SMTPD_CLIENT_RESTRICTIONS =

-o SMTPD_HELO_RESTRICTIONS =

-o SMTPD_SENDER_RESTRICTIONS =

-o myneetworks = 127.0.0.0 / 8

--------------------- Master.cf ---------------------

# vi /usr/local/etc/postfix/main.cf

Content_filter = SMTP-AMAVIS: [127.0.0.1]: 10024

Ok, now a FreeBSD-based function is established, and the virtual domain administrator can log in to OpenWebmail to add, delete, etc., virtual users can modify their own passwords with OpenWebmail.

转载请注明原文地址:https://www.9cbs.com/read-120247.html

New Post(0)