Page 1 of 1

Open File And Send With E-mail

Posted: Mon Nov 18, 2002 8:26 am
by Zeceer
Hi,

I have this script:

Code: Select all

<?php

if( $_POST&#1111;'navn']=="" or $_POST&#1111;'adresse']=="" or $_POST&#1111;'postnummer']=="" or $_POST&#1111;'sted']=="" or $_POST&#1111;'telefon']=="" or $_POST&#1111;'betaling']=="" )
&#123;
        header( "Location: tilkassen_tommefelt.php" );
        exit;
&#125;

$fp = fopen("brukere/".$_POST&#1111;'brukernavn'].$_POST&#1111;'passord'].".php", "r");
$content = fread($fp,filesize("brukere/".$_POST&#1111;'brukernavn'].$_POST&#1111;'passord'].".php"));
fclose($fp);

//MAIL TIL WEBSHOP DRIFTER

$to = "zeceer@hotmail.com";
$subject = "Webshop Bestilling";
$headers = "zeceer@hotmail.com";

$body = "
<br>
<br>
Navn: ".$_POST&#1111;'navn']."
<br>
Adresse: ".$_POST&#1111;'adresse']."
<br>
Postnummer: ".$_POST&#1111;'postnummer']."
<br>
Sted: ".$_POST&#1111;'sted']."
<br>
Telefon: ".$_POST&#1111;'telefon']."
<br>
E-mail: ".$_POST&#1111;'email']."
<br>
<br>
<b>Betaling:</b> ".$_POST&#1111;'betaling']." ".$_POST&#1111;'kortnummer']." - ".$_POST&#1111;'kortdato']."
<br>
<br>".

"
<html>
<body>
$content
</body>
</html>";

mail($to,$subject,$body,"Content-type: text/html; charset=iso-8859-1\r\n");

header( "Location: index.php" );

?>
In the bottom you see a code that includes the HTML from the file that it read at the top. The variable that keeps the info is $content. Content have to be included with the mail. Why want the $content come with the mail? I tried to remove the header in the bottom and replace it with

Code: Select all

print("$content");
After the mail was sent it then printet $content and the info came up in the browser. But the mail that was sent didnt have the info from $content in it at all.

Posted: Mon Nov 18, 2002 8:31 am
by Zeceer
Strange thing is that this script worked fine for a couple of days ago. I haven't done any changes and now it doesn't work :(

Posted: Mon Nov 18, 2002 9:29 am
by volka
hmmmm, works for me.
Have you checked the error log? maybe something (I really don't know what ;) ) worked wrong. And maybe the content is in the mail but the client refuses to show. If possible save the real mail-data from the client and check it with a text-editor

Posted: Mon Nov 18, 2002 10:26 am
by Zeceer
Since it has worked before it may have something to do with the server that recieves it. I don't know. Tried to download the mail and open it in an editor. Still nothing. What kind of mail did you use?


Thought about sending the file as an attachment instead of reading thru the file an print it in the mail. But have do I send a file as an attachment?

Posted: Mon Nov 18, 2002 11:47 am
by volka
I imported the mail to outlook express (I knew it must have been good for something ;) ) and saved it as .eml
From: <testsender@localhost>
To: <testuser@localhost>
Subject: Webshop Bestilling
Date: Mon, 18 Nov 2002 18:40:39 +0100
MIME-Version: 1.0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal


<br>
<br>
Navn: navn
<br>
Adresse: addr
<br>
Postnummer: post
<br>
Sted: sted
<br>
Telefon: tel
<br>
E-mail: email
<br>
<br>
<b>Betaling:</b> betai kort - karto
<br>
<br>
<html>
<body>
<strong>test</strong>
</body>
</html>

Posted: Mon Nov 18, 2002 1:51 pm
by Zeceer
Don't really get it :oops: . Any idea how I can make it work?

Posted: Tue Nov 19, 2002 7:48 am
by Zeceer
After finding out the hard way that this ain't compatibel with all mail clients I'm wondering if anyone know how to send a file as an attachement with PHP. Think this will be better than to read thru the file first for then to print it in the mail. Anyone?