Linux

Debian Linux 7.0 Personal Mail Server Setup Guide

Preparation a) A top-level domain (any registrar), assumed to be test.com b) A personal computer (to act as the server) c) A router with the Peanut Shell (Oray)

  1. Preparation a) A top-level domain (any registrar), assumed to be test.com b) A personal computer (to act as the server) c) A router with the Peanut Shell (Oray) DDNS feature, assumed shell domain name: test.vicp.cc
  2. Domain name resolution

Type

Host

Answer

TTL

Prio

CNAME

*.test.com

test.vicp.cc

60

N/A

MX

test.com

mx.test.com

300

10

TXT

test.com

v=spf1 a mx ~all

300

N/A

  1. Router settings a) Log into the Huake account on the router management page b) Set up port forwarding in the router

  2. Server configuration a) Install the operating system—this article uses Debian Linux 7.0 as an example b) Install software

# apt-get update
# apt-get install sendmail dovecot-imapd dovecot-core dovecot-pop3d apache2 php5

c) Modify the hostname. Edit the /etc/hostname file, changing its contents to: test.com, then run the following command:

# hostname -F /etc/hostname

Modify the /etc/hosts file: add test.com after the 127.0.0.1 entry.

  1. Software configuration

a) Sendmail configuration file directory: /etc/mail

Configuration files that need to be changed: sendmail.mc, access, local-host-names

sendmail.mc

DAEMON_OPTIONS(`Family=inet,  Name=MTA-v4, Port=smtp, Addr=0.0.0.0')dnl #Original text was 127.0.0.1; after this change, the SMTP server is available on all IPs.
dnl MASQUERADE_AS(`localhost')dnl #Comment out this line (add dnl in front), equivalent to modifying sendmail.cf below.

After modifying sendmail.mc, run the command:

# cd /etc/mail
# m4 sendmail.mc > sendmail.cf

>sendmail.cf

# DMlocalhost  #The original text is not commented; if not modified, the sender address will be test@localhost

>access Add the domains allowed to send mail, for example:

sina.com RELAY
google.com RELAY
qq.com RELAY

Run the following command:

# makemap hash access.db < access

local-host-names add: test.com Restart the sendmail service:

Bash

# /etc/init.d/sendmail restart

b) Dovecot configuration directory: /etc/dovecot/conf.d Files to be modified: 10-auth.conf, 10-mail.conf, 10-master.conf, 10-ssl.conf

10-auth.conf Uncomment the following lines

disable_plaintext_auth = yes

10-mail.conf change the mailbox location

Markup

mail_location = mbox:~/mail:INBOX=/var/mail/%u

%u - Username %n - Hostname, the username part of user@domain; if there is none, equivalent to %u %d - Hostname, the domain part of user@domain; if there is none, the home directory %h - Home directory

The following are three formats: mail_location = maildir:/Maildir mail_location = mbox:/mail:INBOX=/var/mail/%u mail_location = mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/%n

For the pros and cons of maildir and mbox, please search on your own. Generally speaking, maildir stores mail in a directory, while mbox stores it in a single text file. My configuration is: "mail_location = maildir:~/mail"

10-master.conf

service imap-login {
    inet_listener imap {
        port = 0
        #port = 143
    }
    inet_listener imaps {
        port = 993
        ssl = yes
    }
}

service pop3-login {
    inet_listener pop3 {
        port = 0
        #port = 110
    }
    inet_listener pop3s{
        port = 0
        #port = 995
        #ssl = yes
    }
}

Only imaps is needed, so disable the imap, pop3, and pop3s port listeners by adding "port = 0" inside the corresponding braces. >10-ssl.conf

ssl = yes
ssl_cert = </etc/dovecot/dovecot.pem
ssl_key = </etc/dovecot/private/dovecot.pem
ssl_ca = </etc/ssl/certs/ca.pem

Remove the comments on the three lines above, and restart the dovecot service.

# /etc/init.d/dovecot restart

For configuring SSL dovecot, refer to: http://wiki2.dovecot.org/SSL/DovecotConfiguration

c) Apache2 configuration file directory: /etd/apache2 (likely a typo for /etc/apache2)

Download SquirrelMail and extract it under /var/www (you can change to a subfolder if you prefer).

For virtual host configuration, please refer to other articles on this blog.

  1. Email account setup a) Add an account
# useradd -m test

b) Change account password

Bash

# passwd test
  1. Send/Receive Mail Test
# echo "hello world" | sendmail -v test@test.com

PS: For mail forwarded via Peanut Shell (花生壳), if configured correctly, you can normally receive mail from other mailboxes, but mail sent to most domains (e.g., sina.com, google.com, qq.com) will be rejected. The reason is that the dynamic IP has been added to a spam-IP blacklist. The author did not find a solution and, for now, paid for a VPS to get by. 8. If you encounter the error "Error connecting to IMAP server "localhost:993". Server error: (111) Connection refused", please install dovecot-pop3d and dovecot-imapd.

N
norvyn

独立 iOS 开发者,写字的人。在一座有海的城市,慢慢地做一些小而确定的东西。An independent iOS developer and writer — slowly making small, certain things in a city by the sea.

评论Comments

加载中…Loading…

留下评论Leave a comment