View Full Version : Why won't it work?!
Mario
07-23-1999, 01:01 AM
I'm sorry, I feel real silly. I simply forgot a semi-colin on the line before. :) Luckily I spared you all from that LONG, excruciating message.
I only wish there were a 24 hour PHP support line somewhere!
[This message has been edited by Mario (edited 07-23-99)]
Mario
07-23-1999, 02:40 PM
So that this topic is not completely WASTED. I do have a valid question now. I am using the mail(function) with my site to do various things after someone registers. However, in the mail function is there a way to just reference a text file for the message instead of typing in the message directly into the mailfunction? Anyone catch my drift?
I'm sure it can be done, anyone know the code?
Thanks. ;)
Justin
07-23-1999, 05:26 PM
The mail() function's job is to send email - that's it. You give it an address, subject, body, and optionally some extra headers, and it sends email :)
However, you can easily open a text file and read it in, mailing out the text. The easiest way to do this is to use the file() function:
$text = join (file ("/path/to/file.txt"), "");
mail ("me@mydomain.com", "Contents of file.txt", $text);
File() returns an array (split by line terminators) of the text in the file, and also works for remote URL's. Since it keeps the line terminators in tact, you can simply join it into a string and mail that out.
Hope you find this helpful :)
------------------
Justin Nelson
FutureQuest Support
Mario
07-23-1999, 11:34 PM
It was extremely helpful Justin, thank you. Now I'm looking to open up a file and WRITE a string to that [flat] file. So I searched PHP.NET and I thought maybe fputs or fwrite() would do the trick, but I don't think they do. (I've tried). Can anyone point me in the right direction to do this?
------------------
vBulletin® v3.6.8, Copyright ©2000-2013, Jelsoft Enterprises Ltd.