Hi,
my problem, as you can see in the header, is that i need a script , which can get the mails of a pop account on the same server, getting the content of the mails, and writing them in a mysql database. The fields are normed, which means i´ve got Name: XXX, Email: XXX and so on. Anyone knows how to do it best, or even better knows where to get such a script ?
Thanks for the help
Christian
Getting POP->Reading Mail->insert in MYSQL
Moderator: General Moderators
-
Christian S
- Forum Newbie
- Posts: 1
- Joined: Wed Aug 07, 2002 5:26 am
- DesignerSMS
- Forum Newbie
- Posts: 17
- Joined: Tue Aug 06, 2002 12:16 am
- Location: Gold Coast, Australia
To do this you would need to connect to the POP3 server manually (using the socket functions), parse the mail message and then save the correct bits into the mySQL database.
Information on the POP3 protocol can be found at http://www.csl.sony.co.jp/cgi-bin/hyperrfc?rfc1081.txt.
Once you have the mail message I would suggest splitting it into separate lines because you have to separate the header from the message body.
A simplified version of an email message directly from a POP3 server looks something like this:
You would need to parse the header one line at a time and get the fields you want to store separately in your database (e.g. From, To, Subject) and then place the rest of the message in the database as well.
There might be some scripts out there to help you do this (at least to interact with a POP3 server). Otherwise, happy coding.
:: Kondro ::
Information on the POP3 protocol can be found at http://www.csl.sony.co.jp/cgi-bin/hyperrfc?rfc1081.txt.
Once you have the mail message I would suggest splitting it into separate lines because you have to separate the header from the message body.
A simplified version of an email message directly from a POP3 server looks something like this:
Code: Select all
Mail From: <user@host.com>
To: <receipient@otherhost.com>
Subject: This is a cool message.
The data goes here.
Notice how there is a blank line separating the header info and the message text.There might be some scripts out there to help you do this (at least to interact with a POP3 server). Otherwise, happy coding.
:: Kondro ::
Last edited by DesignerSMS on Wed Aug 07, 2002 5:38 am, edited 1 time in total.
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK