PDA

View Full Version : email Attach xls file not working properly



[ paul ferrie ]
February 22nd, 2007, 04:03 AM
Hi guys,
I cant see anything wrong but the email i get sent has an empty xls file instead of the file just created.
The file is create and is how it should be but it just not being attached to the email.
Can anyone see anything wrong?


$sdTitle = $_POST['sdTitle'];
$sdName = $_POST['sdFname'];
$sdLast = $_POST['sdLname'];
$sdEmail = $_POST['sdEmail'];
$sdMoby = $_POST['sdMobile'];
$sdAdd1 = $_POST['sdAdd1'];
$sdAdd2 = $_POST['sdAdd2'];
$sdAdd3 = $_POST['sdAdd3'];
$sdAdd4 = $_POST['sdAdd4'];
$sdPost = $_POST['sdAdd5'];
$sdDob = $_POST['sdDob'];
$type = "application/x-msdownload";
$filepath = "temp/";
$file = $sdName."_".$sdLast.".xls";
$bod = "Hi <br>Please find attached ".$file. " file.";
$subject = "Form submission";
//----------------------------------//
function sendmsg($subject, $text, $from, $file, $type) {
$adminaddress = "paul@mydomain.com";
$content = fread(fopen("temp/".$file,"r"),filesize("temp/".$file));
$content = chunk_split(base64_encode($content));
$uid = strtoupper(md5(uniqid(time())));
$name = $file;
$header = "From: $from\nReply-To: $from\n";
$header .= "MIME-Version: 1.0\n";
$header .= "Content-Type: multipart/mixed; boundary=$uid\n";
$header .= "--$uid\n";
$header .= "Content-Type: text/html\n";
$header .= "Content-Transfer-Encoding: 8bit\n\n";
$header .= "$text\n";
$header .= "--$uid\n";
$header .= "Content-Type: $type; name=\"$name\"\n";
$header .= "Content-Transfer-Encoding: base64\n";
$header .= "Content-Disposition: attachment; filename=\"$name\"\n\n";
$header .= "$content\n";
$header .= "--$uid--";
$ok = mail($adminaddress, $subject, "", $header);
if($ok){
echo "&retval=1&";
}
}
//----------------------------------//
// write xls file
$xls_file="<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:x='urn:schemas-microsoft-com:office:excel' xmlns='http://www.w3.org/TR/REC-html40'>
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<head>
<meta http-equiv='Content-type' content='text/html;charset=iso-8859-1' /></head>
<body>
<div id='Classeur1_16681' align=center x:publishsource='Excel'>
<table x:str border=0 cellpadding=0 cellspacing=0 width=100% style='border-collapse: collapse'>
<tr>
<td class=xl2216681 nowrap><b>Title</b></td>
<td class=xl2216681 nowrap><b>First Name</b></td>
<td class=xl2216681 nowrap><b>Last Name</b></td>
<td class=xl2216681 nowrap><b>Address 1</b></td>
<td class=xl2216681 nowrap><b>Address 2</b></td>
<td class=xl2216681 nowrap><b>Address 3</b></td>
<td class=xl2216681 nowrap><b>Address 4</b></td>
<td class=xl2216681 nowrap><b>Postcode</b></td>
<td class=xl2216681 nowrap><b>Mobile Number</b></td>
<td class=xl2216681 nowrap><b>Email</b></td>
<td class=xl2216681 nowrap><b>d.o.b</b></td>
<td class=xl2216681 nowrap><b>OPT IN?</b></td>
</tr>
<tr>
<td class=xl2216681 nowrap>$sdTitle</td>
<td class=xl2216681 nowrap>$sdName</td>
<td class=xl2216681 nowrap>$sdLast</td>
<td class=xl2216681 nowrap>$sdAdd1</td>
<td class=xl2216681 nowrap>$sdAdd2</td>
<td class=xl2216681 nowrap>$sdAdd3</td>
<td class=xl2216681 nowrap>$sdAdd4</td>
<td class=xl2216681 nowrap>$sdPost</td>
<td class=xl2216681 nowrap>$sdMoby</td>
<td class=xl2216681 nowrap>$sdEmail</td>
<td class=xl2216681 nowrap>$sdDob</td>
<td class=xl2216681 nowrap>$sdOpt</td>
</tr>
</table>
</div>
</body>
</html>";
// If file does not exist create and make writeable
if (!file_exists($filepath.$file)){
$handle = fopen($filepath.$file, 'w+');
if (fwrite($handle, $xls_file) === FALSE){
echo '&phpError=Cannot write to file ('.$filepath.$file.').&';
exit;
} else{
sendmsg($subject, $bod, 'no-reply@yourdomain.com', $file,$type);
}
}

Thanks
Paul

borrob
February 22nd, 2007, 04:24 AM
maybe because you don't close the file before sending it.

very nice site by the way!

[ paul ferrie ]
February 22nd, 2007, 05:41 AM
Nope that didnt work either.
Just sends an empty xls file


// If file does not exist create and make writeable
if (!file_exists($filepath.$file)){
$handle = fopen($filepath.$file, 'w+');
if (fwrite($handle, $xls_file) === FALSE){
echo '&phpError=Cannot write to file ('.$filepath.$file.').&';
exit;
} else{
closedir($handle);
sendmsg($subject, $bod, 'no-reply@yourdomain.com', $file,$type);

}

}




very nice site by the way!

Thank you

borrob
February 22nd, 2007, 07:07 AM
closedir???
shouldn't you use close?

[ paul ferrie ]
February 22nd, 2007, 07:10 AM
close() is not a php function

it's fclose()

[ paul ferrie ]
February 22nd, 2007, 07:16 AM
Dam thing is still sending me an empty file :sigh:


$sdTitle = $_POST['sdTitle'];
$sdName = $_POST['sdFname'];
$sdEmail = $_POST['sdEmail'];
$sdMoby = $_POST['sdMobile'];
$sdDayNum = $_POST['sdDayNum'];
$sdAdd1 = $_POST['sdAdd1'];
$sdPost = $_POST['sdPost'];
$sdDob = $_POST['sdDob'];
$sdOpt = $_POST['sdOpt'];
$sdQ1 = $_POST['sdQ1'];
$sdQ2 = $_POST['sdQ2'];
$sdQ3 = $_POST['sdQ3'];
$type = "application/vnd.ms-excel";
$filepath = "temp/";
$file = $sdName."_.xls";
$bod = "Hi <br>Please find attached ".$file. " file.";
$subject = "Form submission";
//----------------------------------//
function sendmsg($subject, $text, $from, $file, $type) {
$adminaddress = "form@mydomain.com";
$content = fread(fopen('temp/'.$file,"r"),filesize('temp/'.$file));
$content = chunk_split(base64_encode($content));
$uid = strtoupper(md5(uniqid(time())));
$name = $file;

$header = "From: $from\nReply-To: $from\n";
$header .= "MIME-Version: 1.0\n";
$header .= "Content-Type: multipart/mixed; boundary=$uid\n";

$header .= "--$uid\n";
$header .= "Content-Type: text/html\n";
$header .= "Content-Transfer-Encoding: 8bit\n\n";
$header .= "$text\n";

$header .= "--$uid\n";
$header .= "Content-Type: $type; name=\"$name\"\n";

$header .= "Content-Transfer-Encoding: base64\n";
$header .= "Content-Disposition: attachment; filename=\"$name\"\n\n";
$header .= "$content\n";

$header .= "--$uid--";

$ok = mail($adminaddress, $subject, "", $header);
if($ok){
//unlink('temp/'.$file);
echo "&retval=1&";
}
}
//----------------------------------//
// write xls file
$xls_file="<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:x='urn:schemas-microsoft-com:office:excel' xmlns='http://www.w3.org/TR/REC-html40'>
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<head>
<meta http-equiv='Content-type' content='text/html;charset=iso-8859-1' /></head>
<body>
<div id='Classeur1_16681' align=center x:publishsource='Excel'>
<table x:str border=0 cellpadding=0 cellspacing=0 width=100% style='border-collapse: collapse'>
<tr>
<td class=xl2216681 nowrap><b>Title</b></td>
<td class=xl2216681 nowrap><b>First Name</b></td>
<td class=xl2216681 nowrap><b>Address 1</b></td>
<td class=xl2216681 nowrap><b>Postcode</b></td>
<td class=xl2216681 nowrap><b>Mobile Number</b></td>
<td class=xl2216681 nowrap><b>Daytime Number</b></td>
<td class=xl2216681 nowrap><b>Email</b></td>
<td class=xl2216681 nowrap><b>d.o.b</b></td>
<td class=xl2216681 nowrap><b>Quesion 1</b></td>
<td class=xl2216681 nowrap><b>Quesion 2</b></td>
<td class=xl2216681 nowrap><b>Quesion 3</b></td>
<td class=xl2216681 nowrap><b>OPT IN?</b></td>
</tr>
<tr>
<td class=xl2216681 nowrap>$sdTitle</td>
<td class=xl2216681 nowrap>$sdName</td>
<td class=xl2216681 nowrap>$sdAdd1</td>
<td class=xl2216681 nowrap>$sdPost</td>
<td class=xl2216681 nowrap>$sdMoby</td>
<td class=xl2216681 nowrap>$sdDayNum</td>
<td class=xl2216681 nowrap>$sdEmail</td>
<td class=xl2216681 nowrap>$sdDob</td>
<td class=xl2216681 nowrap>$sdQ1</td>
<td class=xl2216681 nowrap>$sdQ2</td>
<td class=xl2216681 nowrap>$sdQ3</td>
<td class=xl2216681 nowrap>$sdOpt</td>
</tr>
</table>
</div>
</body>
</html>";
// If file does not exist create and make writeable
if (!file_exists($filepath.$file)){
$handle = fopen($filepath.$file, 'w+');
if (fwrite($handle, $xls_file) === FALSE){
echo '&phpError=Cannot write to file ('.$filepath.$file.').&';
exit;
} else{
fclose($handle);
sendmsg($subject, $bod, 'no-reply@yourdomain.com', $file,$type);
}
}

borrob
February 22nd, 2007, 07:24 AM
YOUR USING $filepath when creating the file but not when sending the attachment.

[ paul ferrie ]
February 22nd, 2007, 07:52 AM
$content = fread(fopen('temp/'.$file,"r"),filesize('temp/'.$file));

If i use


$content = fread(fopen($filepath.$file,"r"),filesize($filepath.$file));

Then the file is named temp_somename_.xls
when it should be somename_.xls
$filepath is "temp/"

I cant believe i still cant get this friggin thing working :(

borrob
February 22nd, 2007, 08:02 AM
you don't get what i mean,
when you create your file it is in temp/
but when you send your attachment you use only filename so where is the path part...

sendmsg($subject, $bod, 'no-reply@yourdomain.com', $file,$type);

sends only filename wich is $name in your function call

$header .= "Content-Disposition: attachment; filename=\"$name\"\n\n";

[ paul ferrie ]
February 22nd, 2007, 08:10 AM
Still getting a friggin empty file:scream:


<?php
$sdTitle = $_POST['sdTitle'];
$sdName = $_POST['sdFname'];
$sdEmail = $_POST['sdEmail'];
$sdMoby = $_POST['sdMobile'];
$sdDayNum = $_POST['sdDayNum'];
$sdAdd1 = $_POST['sdAdd1'];
$sdPost = $_POST['sdPost'];
$sdDob = $_POST['sdDob'];
$sdOpt = $_POST['sdOpt'];
$sdQ1 = $_POST['sdQ1'];
$sdQ2 = $_POST['sdQ2'];
$sdQ3 = $_POST['sdQ3'];
$type = "application/vnd.ms-excel";
//$type = "application/x-msdownload";
$filepath = "temp/";
$file = $sdName."_.xls";
$bod = "Hi <br>Please find attached ".$file. " file.";
$subject = "Form submission";
//----------------------------------//
function sendmsg($subject, $text, $from, $file, $type) {
$adminaddress = "paul@domain.com";

$content = fread(fopen('temp/'.$file,"r"),filesize('temp/'.$file));
$content = chunk_split(base64_encode($content));
$uid = strtoupper(md5(uniqid(time())));
$name = $file;
$fname="temp/".$file;

$header = "From: $from\nReply-To: $from\n";
$header .= "MIME-Version: 1.0\n";
$header .= "Content-Type: multipart/mixed; boundary=$uid\n";

$header .= "--$uid\n";
$header .= "Content-Type: text/html\n";
$header .= "Content-Transfer-Encoding: 8bit\n\n";
$header .= "$text\n";

$header .= "--$uid\n";
$header .= "Content-Type: $type; name=\"$name\"\n";

$header .= "Content-Transfer-Encoding: base64\n";
$header .= "Content-Disposition: attachment; filename=\"$fname\"\n\n";
$header .= "$content\n";

$header .= "--$uid--";

$ok = mail($adminaddress, $subject, "", $header);
if($ok){
//unlink('temp/'.$file);
echo "&retval=1&";
}
}
//----------------------------------//
// write xls file
$xls_file="<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:x='urn:schemas-microsoft-com:office:excel' xmlns='http://www.w3.org/TR/REC-html40'>
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<head>
<meta http-equiv='Content-type' content='text/html;charset=iso-8859-1' /></head>
<body>
<div id='Classeur1_16681' align=center x:publishsource='Excel'>
<table x:str border=0 cellpadding=0 cellspacing=0 width=100% style='border-collapse: collapse'>
<tr>
<td class=xl2216681 nowrap><b>Title</b></td>
<td class=xl2216681 nowrap><b>First Name</b></td>
<td class=xl2216681 nowrap><b>Address 1</b></td>
<td class=xl2216681 nowrap><b>Postcode</b></td>
<td class=xl2216681 nowrap><b>Mobile Number</b></td>
<td class=xl2216681 nowrap><b>Daytime Number</b></td>
<td class=xl2216681 nowrap><b>Email</b></td>
<td class=xl2216681 nowrap><b>d.o.b</b></td>
<td class=xl2216681 nowrap><b>Quesion 1</b></td>
<td class=xl2216681 nowrap><b>Quesion 2</b></td>
<td class=xl2216681 nowrap><b>Quesion 3</b></td>
<td class=xl2216681 nowrap><b>OPT IN?</b></td>
</tr>
<tr>
<td class=xl2216681 nowrap>$sdTitle</td>
<td class=xl2216681 nowrap>$sdName</td>
<td class=xl2216681 nowrap>$sdAdd1</td>
<td class=xl2216681 nowrap>$sdPost</td>
<td class=xl2216681 nowrap>$sdMoby</td>
<td class=xl2216681 nowrap>$sdDayNum</td>
<td class=xl2216681 nowrap>$sdEmail</td>
<td class=xl2216681 nowrap>$sdDob</td>
<td class=xl2216681 nowrap>$sdQ1</td>
<td class=xl2216681 nowrap>$sdQ2</td>
<td class=xl2216681 nowrap>$sdQ3</td>
<td class=xl2216681 nowrap>$sdOpt</td>
</tr>
</table>
</div>
</body>
</html>";
// If file does not exist create and make writeable
if (!file_exists($filepath.$file)){
$handle = fopen($filepath.$file, 'w+');
if (fwrite($handle, $xls_file) === FALSE){
echo '&phpError=Cannot write to file ('.$filepath.$file.').&';
exit;
} else{
fclose($handle);
sendmsg($subject, $bod, 'no-reply@yourdomain.com', $file,$type);
}
}
//
?>

The file that is in temp folder is absolutely fine

[ paul ferrie ]
February 22nd, 2007, 08:13 AM
This is the message source from outlook.

not sure if it helps


To: paul@theory7.com
From: no-reply@yourdomain.com
Reply-To: no-reply@djdomain.com
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=82210469929759F973995E44B664CD64
--82210469929759F973995E44B664CD64
Content-Type: text/html
Content-Transfer-Encoding: 8bit
Hi <br>Please find attached djdomain_.xls file.
--82210469929759F973995E44B664CD64
Content-Type: application/vnd.ms-excel; name="djdomain_.xls"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="temp/djdomain_.xls"
PGh0bWwgeG1sbnM6bz0ndXJuOnNjaGVtYXMtbWljcm9zb2Z0LW NvbTpvZmZpY2U6b2ZmaWNlJyB4
bWxuczp4PSd1cm46c2NoZW1hcy1taWNyb3NvZnQtY29tOm9mZm ljZTpleGNlbCcgeG1sbnM9J2h0
dHA6Ly93d3cudzMub3JnL1RSL1JFQy1odG1sNDAnPg0KPCFET0 NUWVBFIGh0bWwgUFVCTElDICct
Ly9XM0MvL0RURCBYSFRN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m9k
eT4NCjwvaHRtbD4=
--82210469929759F973995E44B664CD64--

[ paul ferrie ]
February 22nd, 2007, 09:58 AM
I still cant get this to work :S
you got any ideas?

Thanks
Paul

[ paul ferrie ]
February 22nd, 2007, 11:21 AM
Sripped the code back trying to check whats going on where and all i know is i dont know jack :S


<?php
$sdTitle = $_POST['sdTitle'];
$sdName = $_POST['sdFname'];
$sdEmail = $_POST['sdEmail'];
$sdMoby = $_POST['sdMobile'];
$sdDayNum = $_POST['sdDayNum'];
$sdAdd1 = $_POST['sdAdd1'];
$sdPost = $_POST['sdPost'];
$sdDob = $_POST['sdDob'];
$sdOpt = $_POST['sdOpt'];
$sdQ1 = $_POST['sdQ1'];
$sdQ2 = $_POST['sdQ2'];
$sdQ3 = $_POST['sdQ3'];
$type = "application/vnd.ms-excel";
//$type = "application/x-msdownload";
$filepath = "temp/";
$file = $sdName."_.xls";
$bod = "Hi <br>Please find attached ".$file. " file.";
$subject = "Form submission";
$subject2 = "Submission received";
$compEmail = "noreply@company.com";
//----------------------------------//
function sendmsg($subject, $text, $from, $file, $type) {
$adminaddress = "paul@djdomain.com";

$content = fread(fopen($file,"r"),filesize($file));
$content = base64_encode($content);
$content = chunk_split($content);
$uid = strtoupper(md5(uniqid(time())));
$name = $file;


$header = "From: $from\nReply-To: $from\n";
$header .= "MIME-Version: 1.0\n";
$header .= "Content-Type: multipart/mixed; boundary=$uid\n";

$header .= "--$uid\n";
$header .= "Content-Type: text/html\n";
$header .= "Content-Transfer-Encoding: 8bit\n\n";
$header .= "$text\n"; //Also text does not appear in email

$header .= "--$uid--\n\n"; //<THis line does not get added for some reason???
$header .= "Content-Type: $type; name=\"$name\"\n";
$header .= "Content-Transfer-Encoding: base64\n";
$header .= "Content-Disposition: attachment; filename=\"$name\"\n\n";
$header .= "$content\n";

$header .= "--$uid--";

$ok = mail($adminaddress, $subject, "", $header);
if($ok){
//unlink('temp/'.$file);
echo "&retval=1&";
}
}
mail($sdEmail, $subject2, "Hi $sdName,
Your submission has been received.

Thanks,
","FROM:".$compEmail);
//----------------------------------//
// write xls file
$xls_file="<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:x='urn:schemas-microsoft-com:office:excel' xmlns='http://www.w3.org/TR/REC-html40'>
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<head>
<meta http-equiv='Content-type' content='text/html;charset=iso-8859-1' /></head>
<body>
<div id='Classeur1_16681' align=center x:publishsource='Excel'>
<table x:str border=0 cellpadding=0 cellspacing=0 width=100% style='border-collapse: collapse'>
<tr>
<td class=xl2216681 nowrap><b>Title</b></td>
<td class=xl2216681 nowrap><b>First Name</b></td>
<td class=xl2216681 nowrap><b>Address 1</b></td>
<td class=xl2216681 nowrap><b>Postcode</b></td>
<td class=xl2216681 nowrap><b>Mobile Number</b></td>
<td class=xl2216681 nowrap><b>Daytime Number</b></td>
<td class=xl2216681 nowrap><b>Email</b></td>
<td class=xl2216681 nowrap><b>d.o.b</b></td>
<td class=xl2216681 nowrap><b>Quesion 1</b></td>
<td class=xl2216681 nowrap><b>Quesion 2</b></td>
<td class=xl2216681 nowrap><b>Quesion 3</b></td>
<td class=xl2216681 nowrap><b>OPT IN?</b></td>
</tr>
<tr>
<td class=xl2216681 nowrap>$sdTitle</td>
<td class=xl2216681 nowrap>$sdName</td>
<td class=xl2216681 nowrap>$sdAdd1</td>
<td class=xl2216681 nowrap>$sdPost</td>
<td class=xl2216681 nowrap>$sdMoby</td>
<td class=xl2216681 nowrap>$sdDayNum</td>
<td class=xl2216681 nowrap>$sdEmail</td>
<td class=xl2216681 nowrap>$sdDob</td>
<td class=xl2216681 nowrap>$sdQ1</td>
<td class=xl2216681 nowrap>$sdQ2</td>
<td class=xl2216681 nowrap>$sdQ3</td>
<td class=xl2216681 nowrap>$sdOpt</td>
</tr>
</table>
</div>
</body>
</html>";
// If file does not exist create and make writeable
if (!file_exists($file)){
$handle = fopen($file, 'w+');
if (fwrite($handle, $xls_file) === FALSE){
echo '&phpError=Cannot write to file ('.$file.').&';
exit;
} else{
fclose($handle);
sendmsg($subject, $bod, $compEmail, $file,$type);
}
}
//
?>

Removed the save path and now the xls file is created in the same dir as the php script

[ paul ferrie ]
February 22nd, 2007, 12:22 PM
it looks like the client has changed there mind a would actually like the xls file to be updated rather than a new one being created for every form submission.
Dont suppose you would have a link to something that could help me out with reading and updating xls files on the server?

Thanks