##Overview You might have a need for a temporary mail service like mailinator.com on your own machine. This guide provides the minimum required steps to do that. The setup we will use is as follows
Procmail (Receive mail and forward to script)--->PHP Script(Parse Mail and put in Database)--->MySQL(Store the mails)--->JSON
Note: This is intended as a quick DIY for simple projects. Hence, we will not go into more details like spam detection and memory optimization.
##Instructions ####Setup Infrastructure
- Get a Top level domain name (Note: Getting this to work with a sub-domain will require more work and setup)
- Change the MX record to point to the public IP of your machine
####Setup Database
- Install mysql on your machine and setup a database to hold your mails.
- Create a table with all the fields you want. A few example fields can be Date, From, Subject, Body etc.
####Setup PHP Script
- Install php on your machine and php-mime-mail-parser. We will be using this library to parse the incoming mails.
- Write a simple file to parse emails from the stdin stream. You can look at the sample file of the library for this.
- You can store the extracted fields into your MySQL database.
####Setup Mail
- Install procmail and postfix
- Edit
/etc/postfix/virtual
file and add the line@yourdomain.com forward
. This will send any mail addressed to any user on yourdomain.com to the user forward. - Execute
postmap /etc/postfix/virtual
- In your
/new/aliases
file, add a forward to your PHP file. This can be done like this ->forward: "|/usr/bin/php -q /var/www/html/proc_mail.php"
- Run
newaliases
to update your aliases - Edit the file at
/etc/postfix/main.cf
and make this changevirtual_alias_maps = hash:/etc/postfix/virtual
- Restart postfix by running
service postfix reload
####Finish
- You can see the incoming mails at /var/log/mail.log
- You can setup a simple php file to retrieve all the emails for a given id and provide the data through JSON.
He'llo sir imm on a project and looking for someone to guide me on selfhosting my own disposable email server as first step of my project.i wish to get some guidance from you