How to NOT send empty files via email? [message #178824] |
Thu, 09 August 2012 15:19 |
Paul
Messages: 3 Registered: February 2012
Karma: 0
|
Junior Member |
|
|
Hi,
I have a simple php page that grabs a .txt file if it exists and emails it.
I would like to modify it so that if the file is under 60 bytes, dont send it.
Here is what I am doing to send the file:
$messageBody .=file_get_contents("d:\notes\note $filedate.txt");
$messageBody .= "\n\r==============================================================\n\r";
$messageBody .=file_get_contents("d:\notes\middaynote $filedate.txt");
ini_set("SMTP", "mailserver");
ini_set("smtp_port", "25");
$headers = "From: reports(at)company(dot)com";
mail("myreport(at)company(dot)com","Here are your reports $today",$messageBody,$headers);
thanks for any help
|
|
|
Re: How to NOT send empty files via email? [message #178825 is a reply to message #178824] |
Thu, 09 August 2012 16:04 |
J.O. Aho
Messages: 194 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 09/08/12 17:19, pauly814(at)gmail(dot)com wrote:
> Hi,
> I have a simple php page that grabs a .txt file if it exists and emails it.
In your example you don't.
> I would like to modify it so that if the file is under 60 bytes, dont send it.
>
> Here is what I am doing to send the file:
> $messageBody .=file_get_contents("d:\notes\note $filedate.txt");
> $messageBody .= "\n\r==============================================================\n\r";
> $messageBody .=file_get_contents("d:\notes\middaynote $filedate.txt");
Check the size of what you get from file_get_contents() of use function
like filesize()
--
//Aho
|
|
|