-
Postfix on RasbPi
Source: Sam Hobbs
-
postfix
sudo apt-get install postfix
y for continue
at the menu select: "Internet Site"
"Tab" to "OK" and "Enter"
Set the mail name to your domain name (without www):
shadow.my-wan.de
change directory
cd /etc/postfix/
sudo nano /etc/postfix/main.cf
add
inet_protocols = ipv4
Check if myhostname =
has the correct hostname
restart postfix
sudo service postfix restart
make backups of the important files:
sudo cp main.cf main.cf.BAK
sudo cp master.cf master.cf.BAK
-
Mailbox Setup
sudo nano /etc/postfix/main.cf
#mailbox_size_limit = 0
home_mailbox = Maildir/
mailbox_command =
-
Dovecot
sudo apt-get install dovecot-common dovecot-imapd
Create amil folders
sudo maildirmake.dovecot /etc/skel/Maildir
sudo maildirmake.dovecot /etc/skel/Maildir/.Drafts
sudo maildirmake.dovecot /etc/skel/Maildir/.Sent
sudo maildirmake.dovecot /etc/skel/Maildir/.Spam
sudo maildirmake.dovecot /etc/skel/Maildir/.Trash
sudo maildirmake.dovecot /etc/skel/Maildir/.Templates
copy files to user
sudo cp -r /etc/skel/Maildir /home/USER/
sudo chown -R USER:USER /home/USER/Maildir
sudo chmod -R 700 /home/USER/Maildir
for user pi:
sudo cp -r /etc/skel/Maildir /home/pi/
sudo chown -R pi:pi /home/pi/Maildir
sudo chmod -R 700 /home/pi/Maildir
-
Initial Testing
First, install telnet:
sudo apt-get install telnet
telnet localhost 25
You can now test sending an email using SMTP. Here are the steps:
send an ehlo command to tell the server who you are, and it will tell you its capabilities
use the mail from command to say who the email is from. If you are sending it from an address that exists on the server, you needn’t include the domain name (i.e. user instead of user@yourdomain.com)
use the rcpt to command to tell the server where to send the email
Use the data command to tell the server that you’re about to start giving it the message you want to send
Type Subject: YOUR SUBJECT then enter to set a subject
Type the body of your email. Once you’re done, press ENTER, then ., then ENTER again.
Type quit to exit
Here’s an example:
telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 shadow.my-wan.de ESMTP Postfix (Debian/GNU)
ehlo foobar
250-shadow.my-wan.de
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
mail from: me
250 2.1.0 Ok
rcpt to: me@outsideemail.com
250 2.1.5 Ok
data
354 End data with .
Subject: test
This is a test email
.
250 2.0.0 Ok: queued as A639C3EE6D
quit
221 2.0.0 Bye
-
Some Access Restrictions
sudo nano /etc/postfix/main.cf
add
smtpd_recipient_restrictions =
permit_sasl_authenticated,
permit_mynetworks,
reject_unauth_destination
Reload postfix:
sudo service postfix reload
-
Helo access restrictions
/etc/postfix/main.cf
smtpd_helo_required = yes
smtpd_helo_restrictions =
permit_mynetworks,
permit_sasl_authenticated,
reject_invalid_helo_hostname,
reject_non_fqdn_helo_hostname,
reject_unknown_helo_hostname
smtpd_helo_restrictions =
permit_mynetworks,
permit_sasl_authenticated,
reject_invalid_helo_hostname,
reject_non_fqdn_helo_hostname,
reject_unknown_helo_hostname,
check_helo_access hash:/etc/postfix/helo_access
sudo nano /etc/postfix/helo_access
Add the following lines, edited for your domain:
shadow.my-wan.de REJECT Get lost - you're lying about who you are
mail.shadow.my-wan.de REJECT Get lost - you're lying about who you are
sudo postmap /etc/postfix/helo_access
sudo service postfix restart
-
Dovecot Part II
sudo nano /etc/dovecot/dovecot.conf
change
listen = *, ::
to
listen = *
sudo service dovecot restart
-
Tell Dovecot where your Mailbox is
sudo nano /etc/dovecot/conf.d/10-mail.conf
change
mail_location = mbox:~/mail:INBOX=/var/mail/%u
to
mail_location = maildir:~/Maildir
-
Instruct Postfix to use Dovecot SASL
add to
sudo nano /etc/postfix/main.cf
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
sudo nano /etc/dovecot/conf.d/10-master.conf
change to
service auth {
unix_listener /var/spool/postfix/private/auth {
mode = 0660
user = postfix
group = postfix
}
}
and check
sudo nano /etc/dovecot/conf.d/10-auth.conf
disable_plaintext_auth = no
auth_mechanisms = plain login
-
Testing SASL
...
cat /var/log/mail.log | less
mailq
sudo postsuper -d ALL
-
TomsMailserver_V_4_2_4
TomsMailserver_V_4_2_4