how can mail server be implemented on localhost using php.i mean to say that how is it possible to send a mail from local client and response it from local host i.e. client and server both are on same computer.please give me the code for it in php.i am new to stackoverflow so please forgive me if my question is not upto your e开发者_如何学Goxpectation.
Your question appears to have two parts: How does one send an e-mail using PHP? and How does one receive an e-mail using PHP?
First of all, there are many ways to send an e-mail using PHP. I would recommend using the SMTP mailing method of one of the many available libraries: PEAR's mail package is a good one (recommended in the PHP manual, actually) and I, personally, have had good experiences with SwiftMailer.
As for retrieving e-mails using PHP, this should be a good place to start researching: http://php.net/manual/en/book.imap.php. I have no experience with this part of your question, so I'm afraid I can't be of much help.
how is it possible to send a mail from local client and response it from local host i.e. client and server both are on same computer
You need to write two seperate programs. One is a Client application used to 'send' the email. The other is the Server application, which receives the email from the Client, and forwards it on to the intended recipient.
For basic SMTP, your Client needs to connect to the server (in this case, localhost) on port 23. Your Server should be listening for those connections on port 23.
As for exactly how you do this, is up to you. There are libraries that make 'sending' an email quite simple (Poss or SwiftMailer), although it's a simple matter to implement the basics yourself, if need be.
Writing a mail server on the other hand, is a much greater task. Is this really what you want to do?
First of all you need a mailserver on your localhost, i you are coding on a *nix platform then you may have postfix installed, you can use that to send/recieve email.
精彩评论