Jump to content

value not passing into mail


sanjay_zed

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/262337-value-not-passing-into-mail/
Share on other sites

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.

$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 <sanjay@kumar.com>'."\r\n";

echo $Recipiant = $temparray[$ii];

mail("$Recipiant",'sanjay bulk email testing',$contents,$headers,'-fsupport@calcipe.com');

}

 

 

this is the above code i am using.

 

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

 

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.