I have a site which maintains a local message database and addressbook. What I would like to do is the following:

When a user contacts another user a record of that message is stored in the message database and an email is also sent to that user. Any response to that email should come back to the server where it is logged into the local message database and forwarded to the original user.

In short I want to trap incoming email, record information on it and redirect it to the proper address. The server I am using has IIS installed, but I am not particular about the email server, cost notwithstanding. I am brand new to email servers and server management in general, so it's a complete mystery. BTW, my web application is written in PHP.

Any help would be appreciated.

Thanks.
David

Recommended Answers

All 2 Replies

Trapping incoming email is the more difficult part. The first article below will give some info on it but if you are using a web hosting service with a shared server, it may depend on what they support. I could not access the incoming mail on my server by forwarding it to a PHP module (I would have had to read it as POP3 or IMAP. The second link provides some code to read the mailbox using POP3.

http://www.evolt.org/article/Incoming_Mail_and_PHP/18/27914/index.html

http://www.weberdev.com/get_example-4015.html

Another approach would be to insert a form or a link into outgoing mail that the recipient would use for replies. This would be their option (they could respond directly) unless you take away that ability by sending from your own address and including originating user id info in the link/form. The messages would always be generated on your site so you would have control of it.

Parsing incoming mail is not a simple task. I wrote a full mime mail parser a while ago:
http://www.bucabay.com/web-development/a-php-mime-mail-parser-using-mailparse-extension/

I also wrote up how to parse incoming mime mail messages.
http://www.bucabay.com/web-development/incoming-mail-php-mime-mail-parser/

Getting the email messages has two parts. First you have to set up your server to accept incoming mail. This is linked in the post above. This is mailserver and platform specific however.

Then parsing the email, which I have linked in my post.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.