Contents of a file can be sent in an email by from "fread" and "mail". "fread" is used to put contents of file in variable. File must be opened first from "fopen" and closed by "fclose". Script must have variables for sender address, recipient address and subject line for mail. Variables are used to make sent headers, with contents of document, by mail.

• Open blank document in any text editor.

• Inert "<?php" to start PHP script.

• Entre following under "$data":

$file="test.txt";
$fh=fopen($file,'r');
$data=fread($fh, filesize($file));
fclose($fh);

• Enter following for setting up sender and recipient mail addresses:
$to_address="recipient@example.com";

$from_address="sender@example.com";

• Enter "$subject="File Contents";" to make subject of email.

• Enter following to set up mail headers:

$headers = 'From: '.$from_address."\r\n".

'Reply-To: '.$from_address."\r\n" .

'X-Mailer: PHP/' . phpversion();

• Enter "mail($to_address, $subject, $data, $headers);" to send email having contents of file.

• Enter "?>" to exit PHP script.

• Save script using ".php" extension.