KoWind
08-22-2002, 10:15 AM
I'm looking for a script to convert a pop3 email into a mySQL entry. Preferably with HTML formatting of the message body.
What I'm attempting to do is be able to send an email to a specific account and have it automaticly enter the news item or calander event, or whatever table I set it for does...
illogix
08-22-2002, 04:40 PM
I think you would have to make a script that would fetch the mail from the pop3 account, then replace all "\n" by "<br>" and then insert it in the database.
You would then need a cron job to run the script via wget every hour or so.
The downside to this is that it would sometimes take up to 1 hour for the changes to take effect but you could always set your cron job to run every 10 minutes but I think it could be a server hug.
UH-Matt
08-22-2002, 10:08 PM
let me know if you come up with anything .. im interested and may help develope such a system.
KDAWebServices
08-23-2002, 07:46 PM
You can setup a pipe in your MTA which will pipe the mail to a PHP script which can read from stdin to get the whole of the email.
KoWind
08-23-2002, 07:57 PM
Could you say that again in English please? I understood most of it, and the theory behind it, but have no idea how to do such a thing...
however, I did find a script that I was able to modify to do what I needed.
Ahmad
08-23-2002, 07:59 PM
It depends on the kind of MTA you are using.
edit: MTA is mail transfer agent, like: qmail, Sendmail, Exim, Postfix.
KDAWebServices
08-23-2002, 08:02 PM
Most MTAs will let you pipe an email e.g. Exim
addy@domain.com: |/path/to/my/file.php
Then in the file you use the PHP I/O functions to read from stdin which will contain the whole of the email including headers.
tsapen
08-24-2002, 07:47 AM
2illogix:
There is no need to replace all "\n" by "<br>" before inserting data into DB. This should be done after selecting data from DB.
2KoWind:
I see two main ways to do it:
1) (easiest to implement) you send "text/plain" email but in the body you place text with HTML tags. Example of email body:
<html>
<body>
<p>
<b>News#1</b>
<br>
Hello world!
</p>
</body>
</html>
Your script just cuts message body and palces it into DB
2) (a little harder to implement) you send "text/HTML" email (i.e. HTML-formated message). Then you script should parse email (extract part with "content-type=text/HTML") and put the message body into DB.
nybble
11-06-2004, 07:23 AM
Originally posted by KDAWebServices
Most MTAs will let you pipe an email e.g. Exim
addy@domain.com: |/path/to/my/file.php
Then in the file you use the PHP I/O functions to read from stdin which will contain the whole of the email including headers.
If you plan to do this on a cpanel box you need PHP in CLI mode not CGI.
By default (stock) its in CGI mode and gives the sender an error message even after it gets to the script. Atleast... in my case.
ibnefahim
10-09-2005, 10:02 PM
i want this type of script if any one made it plz tell me
hammadfahim@gmail.com
i really need it
i m not a good programer that i can make it my self