Jump to content

Email forwarding Program


j5uh

Recommended Posts

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>");

 

Link to comment
Share on other sites

  • Replies 57
  • Created
  • Last Reply

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?

Link to comment
Share on other sites

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);

}

?>

Link to comment
Share on other sites

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);
}
?>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.