This is an SMTP server and Webmail client I made from scratch in PHP.
Requirements :
Installation :
/home/philippe/courriel/
in my case).config.from.txt
file and enter your e-mail address.mbox/
(mbox/p@p97.ca/
in my case).sudo chgrp www-data idx/ sent/sent/ sent/sent.txt ln -s ../sent/sent.txt mbox/zzzsent.txt
Install xinetd and PHP : sudo apt install xinetd php
Create the /etc/xinetd.d/courriel
file and put this in it :
service smtp { socket_type = stream protocol = tcp wait = no user = philippe server = /usr/bin/php server_args = -f /home/philippe/courriel/smtp.php instances = 20 }
(of course, change the two "philippe
" to your username)
Restart xinetd : sudo systemctl restart xinetd.service
Test the server : telnet localhost 25
(then type QUIT
and press Enter)
Create a subdomain pointing to your server's IP address (A record, no CNAME) (mx.example.com
).
Set the MX
record of your domain (example.com
) to mx.example.com
.
Set the TXT
record of your domain to :
v=spf1 a mx a:example.com mx:example.com ip4:10.0.0.1 -all
Of course, change the domains and IP address.
This is required if you want to send mail to Gmail.
Run the following to hash and save your password :
chmod +x pwdgen.sh ./pwdgen.sh
Install apache2 and PHP : sudo apt install apache2 libapache2-mod-php
Create the /etc/apache2/sites-available/courriel.conf
file and put this in it :
<VirtualHost *:80> ServerName webmail.example.com DocumentRoot /home/philippe/courriel/web <Directory /home/philippe/courriel/web/> Require all granted </Directory> </VirtualHost>
(of course, change the two "philippe
" to your username)
Enable the site : sudo a2ensite courriel.conf
Reload apache2 : sudo systemctl reload apache2.service
The Webmail client should now be available.
Configuration :
The config.domainforward.txt
file allows you to forward whole domains to other SMTP servers :
internal.example.com 192.168.2.201 hello.example.com 192.168.2.202
The config.forward.txt
file allows you to forward addresses to other addresses :
hello@public.example.com coucou@internal.example.com