The Dumbster wasn't enough anymore, but I didn't want to install/configure a true e-mail server and maintain it. My new choice is Apache James because it is quite simple to setup and use. It supports MSOutlook and Thunderbird (and many other which I didn't really check).
I'm hosting the the code I'm describing here @github. To run the script successfully you have to place the files configure.sh, apache-james and conflib into the same folder.
Customization
The core of the implementation is the procedure apache_james_v2 (see conflib). The script check if the SUN JDK is already installed, if not try to install it. To skip this step comment out the line containing sun_java at the beginning of the procedure.
The server will be started using the newly created account of the user james. The user james doesn't have the permission to bind a listener to a port less than 1024 so I have to increase the port numbers as follow:
. . .
sed -i s/'<port>110<\/port>'/'<port>4110<\/port>'/g SAR-INF/config.xml
sed -i s/'<port>25<\/port>'/'<port>2525<\/port>'/g SAR-INF/config.xml
sed -i s/'<port>119<\/port>'/'<port>4119<\/port>'/g SAR-INF/config.xml
. . .
The next step is to authorize the IP segment of the development workstations:
. . .
sed -i s/'
<authorizedAddresses>
127.0.0.0\/8
<\/authorizedAddresses>'/'<authorizedAddresses>
127.0.0.0\/8,192.168.1.0\/24
<\/authorizedAddresses>
'/g SAR-INF/config.xml
. . .
The next step adds the mail domains which should be considered as local
. . .
fgrep mail.canistracci.oil SAR-INF/config.xml >/dev/null
if [ "$?" != "0" ]; then
sed -i '/<servername>localhost<\/servername>/ a\
<servername>mail.canistracci.oil<\/servername>' SAR-INF/config.xml
fi
. . .
This code snippet may be repeated for each mail domain which should be handled by James using the syntax mail.<my domain>.
Operations
Using the command sudo service apache-james start James starts-up all configured sections. With stop at the end James terminates the operations and status help you to find out if James is running or not.
Now I have to set up the mail box for my user. First I log in using a telnet client connected on the IP port 4555 as user root with the password root.
Typing adduser petrol petrol, I add the user petrol with the password petrol.
Now I may connect MSOutlook or Thunderbird (new account: POP port 4110, SMTP port 2525) to the POP account petrol/petrol.
As soon as my application sends a mail addressed to petrol@canistracci.oil to the port 2525 my mail client will be able to display it.
No comments:
Post a Comment