PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
The code above runs the file and delivers it to the body of my email. (With more code off-course) What I actually need, is to use a dynamic URL like this:
$headers = "From: My Company <accounts@mysite.com>";
$to = 'myclient@theirmail.com';
$subject = 'Your current statement';
//File to attach
$fileatt = "attach_statement.php";//relative path to the file (this one is in the same directory)
$fileatt_name = "Save Statement to your disc!";//just the name of the file
$file = fopen("http://www. mysite.com/attach_statement.php", "rb");
$data = stream_get_contents($file);
fclose($file);
// Generate a boundary string that is unique
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$message .= "--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n";
// Add the headers for a file attachment
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
$data = chunk_split(base64_encode($data));
// Add file attachment to the message
$message .= "--{$mime_boundary}\n" .
"Content-Type: text/html;\n" . // {$fileatt_type}
" name=\"{$fileatt_name}\"\n" .
"Content-Disposition: inline;\n" .
" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
// Send the message
$send = mail($to, $subject, $message, $headers);
It gives me the statement in the body of my mail as it would appear on my website when called without the variable in the URL. Once I add the variable: http://www.mysite.com/attach_statement.php?id=$id
it delivers nothing to the email body.
is not able to "understand" and/or interpret the parameters... and again.. according to my understanding (I can be wrong), the way to do that is defining a "context" to work with... hence the link that I gave before where the "context" usage is shown and with one example similar to your case....