Forum Moderators: coopster & phranque

Message Too Old, No Replies

file handling

         

ColinJ

4:55 am on Feb 22, 2003 (gmt 0)

10+ Year Member



Gidday all,

I allow my client to send html newsletters from my server, I have given him ftp access to upload his newsletter in html format and his mailing list a text file.

My PHP script slurps in his newsletter and mails it to each of his clients.

I am having troubles with the newsletter, while my program slurps it in correctly, when my program sends it the first few lines of source are removed causing it not to be recieved properly thus either not displaying or displaying incorrectly depending on what email client the receiver has.

<code>
<?

function getFile($filename) {

$output = "";

if ($fp = fopen($filename, 'rb')) {

while (!feof($fp)) {

$output .= fgets($fp, 2048);

}

fclose($fp);

}

return $output;
}

$body = getFile('newsletter6.htm');

if(isset($submit)){

require("./class_mime_mail.php");

include("commonhtml.php");

HTML_Top("Send Mail");

// get resipients

if(!($dataFile = fopen("maillist.txt","r+"))){

print("file could not be opened");

exit;

}

while(!feof($dataFile)){

// read a line from the file

$line = fgetss($dataFile, 255);

if(!($line=="")){

$arrayRecipients[] = $line;

}

}

//$arrayRecipients[] = "colin@domain.au";

//$arrayRecipients[] = "deepesh@domain.au";

$body = $HTTP_POST_VARS['newsletter'];

//print("Body=$body");

while(list($k,$v)=each($arrayRecipients)) {

$current = $v;

echo "Sent to..".$current."<br>";

$mail = new mime_mail();

$mail->from = "rwill@domain.com";

$mail->headers = "Errors-To: colin@domain.au";

$mail->to = $current;

$mail->subject = "The Newsletter 6";

$mail->body = $body;

//$mail->add_attachment("$attachment", "test.jpg", "image/jpeg");

$mail->send();

}

?>

<p align="left">

<a href="admin.php">Return to the Mailing List Manager</a>.

</p>

<?

}
else{

?>
<form name="frmNewsletter" action="<?php echo $PHP_SELF;?>" method="POST">
<textarea name="newsletter" cols="50" rows="20"><? echo $body;?></textarea><br/><br/>
<input type="submit" name="submit" value="submit">
<input type="button" name="preview" value="preview" />
</form>
<?

}
</code>
I know it slurps it in correctly because it displays in the textarea.

when I receive it to my home account viewing it using outlook the first couple of lines of source code are missing. and therefroe doesn't display properly.

[edited by: jatar_k at 5:05 pm (utc) on Feb. 22, 2003]
[edit reason] removed specifics [/edit]

jatar_k

5:09 pm on Feb 22, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Have you tried adding extra headers like

Content-Type: text/html

not sure if that will help but it's a good idea anyway. You could also look through the comments for mail() [php.net]