Reading emails?
I have thought some time about creating a PHP-based customer-service thingy that assigns different types of customer-related stuff to a ticket-id (#).
For starters, I would like to be able read emails from an email account and assign a ticket-id to every new email th开发者_StackOverflow社区at's received.
I have no bloody idea of how I could make PHP read from a email account, or to do whatever that is needed to make this happen, so if anyone here could nudge me in the right direction - it would be fantastic!
This answer might help: How to get email and their attachments from PHP
This will allow each incoming email to process as it comes in without requiring setting up a cron to process them.
You could get a PHP based mail client, or you could look into scraping. Google php email client or check out
http://www.oooff.com/php-scripts/basic-curl-scraping-php/basic-scraping-with-curl
The Zend_Mail_Storage_* components from Zend Framework provide reading mail.
Supported storage types are:
- local
- Mbox
- Maildir
- remote
- Pop3
- IMAP
They provide a convenient and clean api.
// connecting with Imap
$mail = new Zend_Mail_Storage_Imap(array(
'host' => 'example.com',
'user' => 'test',
'password' => 'test'
));
$maxMessage = $mail->countMessages();
foreach ($mail as $messageNum => $message) {
// output subject of message
echo $message->subject . "\n";
// output message content for HTML
echo '<pre>';
echo $message->getContent();
echo '</pre>';
}
Give this a try pop3 mail class
I used it some time ago , and it worked, but you have to make some mime parsing, so start looking at this and you will get the ideea
精彩评论