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
Share on other sites

1. Are wanting literal message saved that was sent, e.g.

<a href='http://www.example.com/thankyou.php?email=testmail@hi.com'>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>

 

 

 

Link to comment
Share on other sites

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.

Link to comment
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.

Link to comment
Share on other sites

$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.

 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.