Hi,
The following code is part of code that works when I plug the actual filename say, howtodoit.zip , into the two positions highlighted in red.
Instead of the actual filename I want to use a variable containing that filename say, $filename.
Can you show me how this is achieved.
I have plugged in the variable name $filename but although echoing shows that a legitimate file is in this variable, and the program returns "sent" it is not delivered and another massage tells me the message has been saved as dead.mail in a directory that GODADDY will not allow me access to.
Thanks,
D
$attachment = chunk_split(base64_encode(file_get_contents('[COLOR="Red"]howtodoit.zip[/COLOR]')));
//define the body of the message.
ob_start(); //Turn on output buffering
?>
--PHP-mixed-<?php echo $random_hash; ?>
Content-Type: multipart/alternative; boundary="PHP-alt-<?php echo $random_hash; ?>"
--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
You have an attachment
--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
<h2>Hello </h2>
<p>You have an attachment! <b>HTML</b>See Attachment</p>
--PHP-alt-<?php echo $random_hash; ?>--
--PHP-mixed-<?php echo $random_hash; ?>
Content-Type: application/zip; name= "[COLOR="Red"]howtodoit.zip[/COLOR]"
Content-Transfer-Encoding: base64
Content-Disposition: attachment
<?php echo $attachment; ?>
--PHP-mixed-<?php echo $random_hash; ?>--
<?php
//copy current buffer contents into $message variable and delete current output buffer
$message = ob_get_clean();
//send the email
$mail_sent = @mail( $to, $subject, $message, $headers );
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
echo $mail_sent ? "Mail sent" : "Mail failed";
}
//end code for sending zipfile by attachment