RE: [PHP] Insert Record in MySQL Database from eMail
| From: | Warren Vail | Date: | Wed, 14 May 2003 14:52:04 +0000 |
| Subject: | RE: [PHP] Insert Record in MySQL Database from eMail | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-147591@lists.php.net to get a copy of this message | ||
As you would probably expect, what you want to do is a little more complex
than it first sounds like.
First to get email content, you need to have a POP3 or IMAP server running
on your system at all times to receive the email (all times because incoming
clients need to be able to send email there at ANY time). This server will
need to handle multiple simultaneous connections.
Your PHP code can establish a connection with this POP3 or IMAP server
(username and password required) download headers, then process each email,
storing it in your database. See http://www.php.net/manual/en/ref.imap.php
for more info, but you will find that these routines give you the
from/to/subject already broken out as separate objects. One thing perhaps
not obvious, is that many emails include multiple mime formats in the body
(html, or text) and you will need to decide which you want to store in your
database, each has its advantages. Then of course, if there are
attachments,,,, they too will appear as separate objects. As you process
each email, you will mark it has having been read, and at the very end
"expunge" or remove the read mail from your server, unless of course, you
have some reason to leave a copy there.
Someone may have already written routines that do exactly what you want to
do. You could start looking at;
http://www.hotscripts.com/PHP/Scripts_and_Programs/Email_Systems/
good luck,
Warren Vail
warren@vailtech.net
-----Original Message-----
From: Vernon [mailto:vernon@comp-wiz.com]
Sent: Wednesday, May 14, 2003 7:19 AM
To: php-general@lists.php.net
Subject: [PHP] Insert Record in MySQL Database from eMail
I have a need to have a record created based on email content.
I know there is a way to feed emails to a program so I'm assuming that any
email can be submitted to some type of script that would allow me to add the
content of said email into a database record. An ideal situation would be to
be able to strip the e-mail's "from" field, "subject" field,
"content" field
and so forth and add that info to separate fields in a table in the
database.
Any one have any ideas on how to go about doing that? Better yet a script or
how-to I see?
Thanks
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php