rubing Posted June 4, 2008 Share Posted June 4, 2008 try the following: function get_string_between($string, $start, $end){ $string = " ".$string; $ini = strpos($string,$start); if ($ini == 0) return ""; $ini += strlen($start); $len = strpos($string,$end,$ini) - $ini; return substr($string,$ini,$len); } $email = get_string_between($email, "<div class=3DSection1>", "</div>"); Quote Link to comment Share on other sites More sharing options...
j5uh Posted June 4, 2008 Author Share Posted June 4, 2008 99% there!!! i typed this in the email nowei dowe dqwmopqwm but it's showing up like this when i get it nowei dowe = dqwmopqwm with an equal sign... how do I not make those appear? Quote Link to comment Share on other sites More sharing options...
rubing Posted June 4, 2008 Share Posted June 4, 2008 dunno. Quote Link to comment Share on other sites More sharing options...
j5uh Posted June 5, 2008 Author Share Posted June 5, 2008 ok one more issue. now I've stuck in some code to pull the email addresses from the db, but im getting this error here: Fatal error: Cannot redeclare get_string_between() (previously declared in /home/newhost/public_html/asd/asd/mailer3.php:28) in /home/newhost/public_html/asd/asd/mailer3.php on line 28 here's the code I am using: #!/usr/bin/php <?php $db_host = "asd"; $db_user = "asd"; $db_pwd = "asd"; $db_name = "asd"; $db_table = "users"; $db_emailfield = "email"; mysql_connect($db_host, $db_user, $db_pwd); mysql_select_db($db_name); $sql = "SELECT `$db_emailfield` FROM `$db_table`;"; $result = mysql_query($sql); while($row = mysql_fetch_assoc($result)){ $emails = $row['email']; $ChangeTo = 'asd; // read from stdin $fd = fopen("php://stdin", "r"); $email = ""; while (!feof($fd)) { $email .= fread($fd, 1024); } fclose($fd); function get_string_between($string, $start, $end){ $string = " ".$string; $ini = strpos($string,$start); if ($ini == 0) return ""; $ini += strlen($start); $len = strpos($string,$end,$ini) - $ini; return substr($string,$ini,$len); } $email = get_string_between($email, "<div class=3DSection1>", "</div>"); // handle email $lines = explode("\n", $email); // empty vars $from = ""; $subject = "Expert Advisors"; $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; } } $headers = 'MIME-Version: 1.0' . "\n"; $headers .= 'Content-type: text/html; charset=UTF-8' . "\n"; $headers .= "From: asd"; $ForwardTo = $emails; mail ($ForwardTo,$subject,$message,$headers); } ?> Quote Link to comment Share on other sites More sharing options...
j5uh Posted June 5, 2008 Author Share Posted June 5, 2008 I've finally figured it out. here's the final code to share it with the world. #!/usr/bin/php <?php $db_host = "xxx"; $db_user = "xxx"; $db_pwd = "xxx"; $db_name = "xxx"; $db_table = "users"; $db_emailfield = "email"; mysql_connect($db_host, $db_user, $db_pwd); mysql_select_db($db_name); // read from stdin $fd = fopen("php://stdin", "r"); $email = ""; while (!feof($fd)) { $email .= fread($fd, 1024); } fclose($fd); function get_string_between($string, $start, $end){ $string = " ".$string; $ini = strpos($string,$start); if ($ini == 0) return ""; $ini += strlen($start); $len = strpos($string,$end,$ini) - $ini; return substr($string,$ini,$len); } $email = get_string_between($email, "<div class=3DSection1>", "</div>"); // handle email $lines = explode("\n", $email); // empty vars $from = ""; $subject = "your subject here"; $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; } } $sql = "SELECT `$db_emailfield` FROM `$db_table`;"; $result = mysql_query($sql); while($row = mysql_fetch_assoc($result)){ $emails = $row['email']; $headers = 'MIME-Version: 1.0' . "\n"; $headers .= 'Content-type: text/html; charset=UTF-8' . "\n"; $headers .= "From: your address.com"; $ForwardTo = $emails; mail ($ForwardTo,$subject,$message,$headers); } ?> Quote Link to comment Share on other sites More sharing options...
rubing Posted June 6, 2008 Share Posted June 6, 2008 good job! are you addicted yet? Quote Link to comment Share on other sites More sharing options...
j5uh Posted June 6, 2008 Author Share Posted June 6, 2008 good job! are you addicted yet? HIGHLY addicted. I've even bought a book and i'm reading about php everyday now. Quote Link to comment Share on other sites More sharing options...
rubing Posted June 6, 2008 Share Posted June 6, 2008 yeah it's pretty cool! if you want to get on the php people's good side then lookup rasmus lerdorf and make lots of references to him whenever you post!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.