Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,179,903 members, 7,909,399 topics. Date: Saturday, 03 August 2024 at 01:16 AM |
Nairaland Forum / Science/Technology / Programming / Help Needed With A Php Piping Script (urgent) (1555 Views)
How To Program A PHP SMS Gateway / What Is The Average Salary Of A Php Programmer In Lagos / I Need Help With A PHP Script (2) (3) (4)
Help Needed With A Php Piping Script (urgent) by internetpo(m): 5:58pm On Sep 25, 2009 |
Help! I have been working for a while with my programmer brother on a PHP piping script but have not yet succeeded yet. the script was supposed to pipe/ direct several e-mails from a certain address to a MYSQL database . But we dont seem to be getting the IMAP/ POP 3 settings correctly or maybe something else is wrong. Need help to complete the project at hand, any ideas, pls anybody. I have a deadline. |
Re: Help Needed With A Php Piping Script (urgent) by segsalerty(m): 5:22pm On Sep 27, 2009 |
can anyone understand what Poster really needs? cant understand the problem pipe/ direct several e-mails from a certain address to a MYSQL database |
Re: Help Needed With A Php Piping Script (urgent) by Nobody: 3:48pm On Sep 28, 2009 |
have you tried reading the imap in ur php manual, its easy |
Re: Help Needed With A Php Piping Script (urgent) by internetpo(m): 9:49pm On Sep 29, 2009 |
webdezzi:we have tried it but it didn't work. Do I paste the piping script here. |
Re: Help Needed With A Php Piping Script (urgent) by Nobody: 10:07am On Sep 30, 2009 |
why not. i will suggest that the script checks ur mail directory for new mails instead which means d script must be run whenever u wanna check for new mails. same way outlook does. |
Re: Help Needed With A Php Piping Script (urgent) by yawatide(f): 7:18pm On Oct 02, 2009 |
have you tried reading the imap in your php manual, its easy it is only easy for the person who knows. If you doubt me, oya tell me how to go about manufacturing a rocket that can land you safely on mars? |
Re: Help Needed With A Php Piping Script (urgent) by Nobody: 11:34pm On Oct 04, 2009 |
now where is the script? it appears the top-class webmasters are around but no script to debug! |
Re: Help Needed With A Php Piping Script (urgent) by internetpo(m): 7:40am On Oct 06, 2009 |
Ok, here is the Ogbonge Script [b]#!/usr/local/bin/php -q <?php error_reporting(0); // read from stdin $fd = fopen("php://stdin", "r" $email = ""; while (!feof($fd)) { $email .= fread($fd, 1024); } fclose($fd); // handle email $email=strip_tags ($email); $lines = explode("\n", $email); // empty vars $from = ""; $subject = ""; $headers = ""; $message = ""; $splittingheaders = true; for ($i=0; $i < count($lines); $i++) { if ($splittingheaders) { // this is a header $headers .= $lines[$i]."\n"; // look out for special headers if (preg_match("/^Subject: (.*)/", $lines[$i], $matches)) { $subject = $matches[1]; } if (preg_match("/^From: (.*)/", $lines[$i], $matches)) { $from = $matches[1]; } } else { // not a header, but message $message .= $lines[$i]."\n"; } if (trim($lines[$i])=="" { // empty line, header section has ended $splittingheaders = false; } } preg_match("/boundary=\".*?\"/i", $headers, $boundary); $boundaryfulltext = $boundary[0]; if ($boundaryfulltext!="" { $find = array("/boundary=\"/i", "/\"/i" $boundarytext = preg_replace($find, "", $boundaryfulltext); $splitmessage = explode("--" . $boundarytext, $message); $fullmessage = ltrim($splitmessage[1]); preg_match('/\n\n(.*)/is', $fullmessage, $splitmore); if (substr(ltrim($splitmore[0]), 0, 2)=="--" { $actualmessage = $splitmore[0]; } else { $actualmessage = ltrim($splitmore[0]); } } else { $actualmessage = ltrim($message); } $clean = array("/\n--.*/is", "/=3D\n.*/s" $cleanmessage = trim(preg_replace($clean, "", $actualmessage)); // test action to be replaced by db insertion code $body = "$cleanmessage"; //forward email mail('myemailaddressgoeshere', $subject, $body, "From: ".$from); The forwarding works well, i get the mail forwarded to the email address. //connect to sql $db = mysql_connect ('localhost','don't worry','don't worry'); //select the database you created mysql_select_db('don't worry', $db); $query="INSERT INTO recievedMails(from,subject,headers,message) VALUES('".$from."','".$subject."','".$headers."','".$body."')"; $result = mysql_query($query); ?>[/b] Expecting your help webmasters, thanks |
Re: Help Needed With A Php Piping Script (urgent) by internetpo(m): 7:51am On Oct 06, 2009 |
by the way. WE have succeeded in Piping from one e-mail to another. but from one e-mail to a database has been hell, it seems not to be working. |
Re: Help Needed With A Php Piping Script (urgent) by yawatide(f): 9:35am On Oct 06, 2009 |
1) This is how I write my sql insert statements: $result = mysql_query("INSERT into tbl_subscription values (NULL, '$autoAssignedId', '$subscription', '$subscribedItem')" NOTE the absence of "." around '$autoAssignedId' (just in case you don't understand, see how you have the "From" written as '".$from." 2) What has always worked for me and DBs is printing out the value of my statements. Do an echo and exit after the statement to see if you actually have any values. 3) I don't see any checks after you insert like so: if(!$result) return 'Could not pipe into the database at this time. '; Try the above if not already and get back to us. good luck! |
Re: Help Needed With A Php Piping Script (urgent) by Nobody: 2:52pm On Oct 07, 2009 |
yawa-ti-de: maybe if you import the rocket module for python you should land safely, |
Re: Help Needed With A Php Piping Script (urgent) by yawatide(f): 3:23pm On Oct 07, 2009 |
internetpro (and to all others who may fall in the same category): I forgot to mention this - Next time, please indent your code. The way you have it up there (and I hope this isn't a reflection of your actual code ), it is very hard to read and follow the logic. You want us to help you. Help speed up the process by making it easier for us to read and follow your code Thanks. |
Re: Help Needed With A Php Piping Script (urgent) by Nobody: 5:24pm On Oct 07, 2009 |
Now, that code appears to be in order, i did not check it thoroughly, now, how did you configure it on your control panel? that may be where the issue is! i need to know how you implemented it. |
Re: Help Needed With A Php Piping Script (urgent) by internetpo(m): 10:29am On Oct 13, 2009 |
@ *dhtml I did not upload it to the public directory of my cpanel becos of security reasons. I uploaded it to the home directory and made the file permission executable. |
Re: Help Needed With A Php Piping Script (urgent) by fastchange: 3:24pm On Oct 13, 2009 |
yawa-ti-de: For even more clarity ur SQLs can look like this: $sql = "INSERT INTO table SET feild1 = {$feild_value1}, feild2 = {$feild_value2}, feild3 = {$feild_value3}, feild4 = {$feild_value4}"; $result = mysql_query($sql); . . . . I know this is not your fish bone but it helps alot in detecting errors a all that. |
(1) (Reply)
C++, Ruby, Coffeescript: A Visual Comparison Of Language Complexity / Do You Think You Can Develop A Search Engine From Scratch? / I Need A Teacher
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 23 |