-
Notifications
You must be signed in to change notification settings - Fork 21
Email handling
In order to have incoming email in our app we set up Exim4 for multiple virtual domains. (Thanks to @dracos to set us in the right path)
We set up exim4 according to guide
Install exim4 package
apt-get install exim4-daemon-heavy
Configure the exim package
sudo dpkg-reconfigure exim4-config
This is what we answered
-
internet site; mail is sent and received directly sing SMTP
-
System mail name > writeit.ciudadanointeligente.org
-
IP-addresses to listen on for incoming SMTP connections > Empty
-
Other destinations for which mail is accepted > writeit.ciudadanointeligente.org
-
Domains to relay mail for > writeit.ciudadanointeligente.org; *.writeit.ciudadanointeligente.org
-
Machines to relay mail for > Empty
-
Keep number of DNS-queries minimal (Dial-on Demand)? > No
-
Delivery method for local mail > mbox
-
Split configuration into small files? > Yes
-
Directory for root and postmaster mail > Empty
We create a directory called virtual in /etc/exim4
mkdir /etc/exim4/virtual
Create a file with the name of the domain in our case this will be writeit.ciudadanointeligente.org
vim /etc/exim4/virtual/writeit.ciudadanointeligente.org
With the content
* : ubuntu@localhost
local_part_suffix = +* : -*
local_part_suffix_optional
We modified the file /etc/exim4/conf.d/main/01_exim4-config_listmacrosdefs where we replaced
domainlist with domainlist local_domains = @:localhost:dsearch;/etc/exim4/virtual
We created the file /etc/exim4/conf.d/router/350_exim4-config_vdom_aliases with the content:
vdom_aliases:
driver = redirect
allow_defer
allow_fail
domains = dsearch;/etc/exim4/virtual
data = ${expand:${lookup{$local_part}lsearch*@{/etc/exim4/virtual/$domain}}}
retry_use_local_part
pipe_transport = address_pipe
file_transport = address_file
no_more
Then restarted:
sudo service exim4 restart
Then we created at /home/ubuntu a file called .forward with the content
|/home/ubuntu/handleemail.py
Then we added two mx records with the value writeit and name ciudadanointeligente.org and priority 1 and the other one with value writeit but name writeit.ciudadanointeligente.org and priority 5.
Then because we are using amazon AWS we had to open the ports 25 and 465 in the security group for the instance which is running exim.
Then we changed the permissions in the file .forward to 644 and we added execution permissions to the handleemail.py:
` chmod 644 .forward
chmod +x handleemail.py `