sanjay_zed Posted May 10, 2012 Share Posted May 10, 2012 i am sending a mail to user (user's email is stored in $email) in body i have written code $message =" <a href='http://www.example.com/thankyou.php?email=".$email."'>click here to join</a> "; now i need this content to be stored in database and has to be retreived and append it to body like $message =$body_from_db; if i check it in mail. the corresponding value of $email is not coming . pls help guys. Quote Link to comment https://forums.phpfreaks.com/topic/262337-value-not-passing-into-mail/ Share on other sites More sharing options...
Drummin Posted May 10, 2012 Share Posted May 10, 2012 1. Are wanting literal message saved that was sent, e.g. <a href='http://www.example.com/[email protected]'>click here to join</a> 2. Or the variable $email <a href='http://www.example.com/thankyou.php?email=".$email."'>click here to join</a> Quote Link to comment https://forums.phpfreaks.com/topic/262337-value-not-passing-into-mail/#findComment-1344406 Share on other sites More sharing options...
sanjay_zed Posted May 10, 2012 Author Share Posted May 10, 2012 i will be sending mails to users more than one . i need to track who has clicked on that mail. so i am passing the user's email id along with body. if that script is stored in database. i couldnt able to retreive email id. Quote Link to comment https://forums.phpfreaks.com/topic/262337-value-not-passing-into-mail/#findComment-1344408 Share on other sites More sharing options...
Drummin Posted May 10, 2012 Share Posted May 10, 2012 Then you should be storing the actual email of the person. Assuming this is being executed in a loop where the variable $email is set as in when sending the email message. $message =" <a href='http://www.example.com/thankyou.php?email=".$email."'>click here to join</a> "; $message=mysql_real_escape_string($message); //Do your insert query here into DB message='{$message}' //Change to a real query storing the variable $message. Quote Link to comment https://forums.phpfreaks.com/topic/262337-value-not-passing-into-mail/#findComment-1344413 Share on other sites More sharing options...
sanjay_zed Posted May 10, 2012 Author Share Posted May 10, 2012 $sql="SELECT * FROM email_list "; $res= mysql_query($sql); $temparray=array(); while($row=mysql_fetch_assoc($res)) { array_push($temparray,$row["email"]); } $totalmail=count($temparray); for($ii=0;$ii<$totalmail;$ii++){ $email = $temparray[$ii]; $contents=""; $contents=" <a href='http://www.example.com/bulkEmail/thankyou.php?email=".$email."'>click here to join</a> <br/> "; } $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: sanjay <[email protected]>'."\r\n"; echo $Recipiant = $temparray[$ii]; mail("$Recipiant",'sanjay bulk email testing',$contents,$headers,'[email protected]'); } this is the above code i am using. Quote Link to comment https://forums.phpfreaks.com/topic/262337-value-not-passing-into-mail/#findComment-1344424 Share on other sites More sharing options...
Drummin Posted May 10, 2012 Share Posted May 10, 2012 Right not mail() in not inside query results loop OR the FOR() loop you've made so only the last instance of the variable $email would be available. I see no reason to build an array here. while($row=mysql_fetch_assoc($res)) { $contents=""; $contents=" <a href='http://www.example.com/bulkEmail/thankyou.php?email=".$row['email']."'>click here to join</a> <br/> "; // Add DB INSERT CODE HERE IF SAVING TO DB //CONTINUE WITH EMAIL CODE Headers etc. }//Closing while loop Quote Link to comment https://forums.phpfreaks.com/topic/262337-value-not-passing-into-mail/#findComment-1344539 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.