I am asking for help, after hours of trying to figure this out myself.
I have the following code, which I would like to email results to email.
Here is my code:
$emailme = "[email protected]";
$subject = "Randomly selected from array";
$headers = "From: $emailme\n";
$message = "Here is the Randomly selected from array.\n
Random text: $r_array";
$r_array=file('file.txt');
shuffle($r_array);
$output = "<p><center><b>The Randomly Selected Text is:</b></p><b>" .
$r_array[0] . "All done, echoing results.";
mail($emailme,$subject,$message,$headers);
So far, I am able to echo the results to screen, but am unable to send results via email.
Sending an email is pretty straight forward, example:
<?php
$r_array=file('file.txt');
shuffle($r_array);
$to = "[email protected]";
$subject = "Random Selected Text";
$body = "<p><center><b>The Randomly Selected Text is:</b></p><b>" . $r_array[0] . "All done, echoing results.";
if (mail($to, $subject, $body)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
?>
Something like this should work, if not, the mail server might not be properly configured on the web server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With