Don Alexander Eckford's code for standard email:


Warning: Undefined variable $to in /home/eckfordd/public_html/citw185/examples/email3.php on line 27

Deprecated: mail(): Passing null to parameter #1 ($to) of type string is deprecated in /home/eckfordd/public_html/citw185/examples/email3.php on line 27

Warning: Undefined variable $to in /home/eckfordd/public_html/citw185/examples/email3.php on line 34
Email sending failed. Please try again later.
 

CODE FOLLOWS

<?php

    
include('includes/header.php');

    
error_reporting(E_ALL);
    
ini_set('display_errors'1);

    echo(
"<h1>Don Alexander Eckford's code for standard email:</h1>");

    
//$to = 'eckfordd@mail.lcc.edu';
    
$from_address 'eckfordd@mail.lcc.edu';
    
$from_name 'Don Alexander Eckford';

    
$body "<html><body>";
    
$body .= "<h1>This is from a more complicated mail script!</h1>";
    
$body .= "<p>Enjoy your email.</p>";
    
$body .= "</body></html>";
    
$subject "More complicated mail (CITW)";
    
$eol "\r\n";

    
$headers  "From: ".$from_name."<".$from_address.">" $eol;
    
$headers .= "Reply-To: ".$from_name."<".$from_address.">" $eol;
    
$headers .= "Content-Type: text/html; charset=utf-8" $eol;

    
ini_set('sendmail_from'$from_address);

    
$mail_sent mail($to$subject$body$headers);

    
ini_restore('sendmail_from');

    if (
$mail_sent) {
        echo(
"Successfully sent an email to: $to");
    } else {
        
error_log("Mail function failed to send email to $to.");
        echo 
"Email sending failed. Please try again later.";
    }

    include(
'includes/footer.php');
?>