Hi all, would just like to ask for your expertise here.
I've written this PHP script which runs with cron to pick a line from a text file and send it as a "word of the day" email.
Currently it works exactly as I wanted it to. What I'd like to ask here is:
//The name of the tab-separated text file containing the vocab list
$vocab_file = "path to text file";
//Read the vocab text file
$vocab_list = file($vocab_file);
//Grab a random line from the vocab text
$todays_item_string = $vocab_list[array_rand($vocab_list)];
//Make that line into an array (tab separated)
$todays_item_array = explode("\t", $todays_item_string, 4);
//Get the details of today's word fromt that array
$word = $todays_item_array;
$reading = $todays_item_array;
$meaning = $todays_item_array;
//The information for the email
$recipient = "email address";
$subject = $word . " (" . $reading . "): " . $meaning;
$message = "
<p>Today's word of the day is <span style='font-size:x-large;'>" . $word . "</span> (" . $reading . "), which means " . $meaning . "</p>
<p style='font-size:7em; text-align:center;'>" . $word . "</p>
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
//Send the email with today's word
mail($recipient, $subject, $message, $headers);
- Could it be made more efficient?
- Is it secure?
Regarding the security, I run the script from a folder not in www, and the .htaccess in that folder is:
The vocab file is 644 and the script itself is 740. Any security concerns there?
Deny From All
Allow From localhost
I'd be really grateful for any help with this!