Can you receive emails through PHP?
I know you can send emails with PHP but, can you 开发者_JAVA百科receive emails through PHP?
You can pipe incoming mails into a PHP script so you can process it directly. Evolt has an article on how to setup something like that. This can be useful if you want to activate scripts programmatically by sending Emails to it (like responses to a newsletter mail that unsubscribes the user).
If you just want to read mails using PHP, PHP has native functions to talk to IMAP, NNTP and POP mailboxes.
Take a look at http://cloudmailin.com it takes away a lot of the hassle involved with receiving the email and will send it directly to your app via an HTTP Post. We have quite a few php users using the system to receive email.
You could write a mail server in PHP that binds to a port and listens for incoming email.
But PHP is not the language I would recommend for tasks like this, and it would also be a hugely complex undertaking.
You can hook into an existing mail server as callback script, or periodically query a mail server via POP or IMAP. The latter option is the most common: run a PHP script that processes an email account via a cron task in intervals. See http://php.net/imap.
There is a great library that is based on IMAP extension: http://code.google.com/p/php-imap
Only a mail server can receive e-mails. You could read mail box formats (such as mbox or Maildir) to read e-mail using PHP.
PHP scripts functioning as IMAP/POP3 servers can receive e-mail sent to them.
精彩评论