tags:

views:

331

answers:

3

1) How can a linux server be configured such that it can receive any emails sent to [email protected].

2) How can these emails be accessed and displayed by a PHP script?

I'm building a simple web mail script, so i want to receive emails only for the registered email accounts and classify their emails and show them.

Needs also to have the ability to show attachments.

A: 

You have a lot of work in front of you - don't expect someone to just post some code here.

Start by reading the POP3, SMTP, and IMAP RFCs. Then go find a commercial/open source solution.

Frank Krueger
Lol, what're the general things I need to do?
Click Upvote
Are there any libraries that make it any easier or is it all server work?
Click Upvote
Request Tracker (RT: http://bestpractical.com/rt/ ) is a PHP package that does this. Check it out.
Nerdling
+1  A: 

The mail server itself can be setup to receive email with any number of MTA's (sendmail, postfix, exim, etc). You'll want SPAM protection and Virus scanning as well (again there are free packages in any distribution for this). Be warned, running your own mail server is NOT a job for the faint of heart these days.

Once that's in place I would probably setup IMAP and use PHP's IMAP functions to retrieve and parse the messages. Viewing attachments will be a lot harder if you want them readable in the browser, but easy to mark that they are there and make them downloadable.

There is likely a class already written that does most of this for you (excepting the setup of course).

Update: In fact there is an old article at evolt that appears to cover this.

acrosman
+2  A: 

Honestly, you're better off looking at one of the webmail systems already out there and modifying it to fit your needs rather than writing something from scratch.

The email RFCs are a fun read (no, no they're not) and attachment handling has caused many developers to take up heavy drinking. Don't get me wrong, it can be done. Its just a lot of work and not something that you want to take on unless you have a bunch of time to dig deep into it.

However, if you wanted to write something quick and simple, I suggest setting up a linux box with an Imap or pop server and then accessing that mailbox with the appropriate PHP / Pear libraries. That will be the quickest way to get going.

But I would still recommend using one of the off the shelf solutions that are out there and hacking it up to fit your needs.

usrlocal
And what php/pear libraries are those?
Click Upvote
The Pear library is here: http://pear.php.net/package/Mail_IMAP/PHP also has some built in functions if you have the right support loaded in and those functions are here: http://us3.php.net/imap
usrlocal