Including HTML in PHP mail Function -
Including HTML in PHP mail Function -
this question has reply here:
html in php mail service function 1 replyi have read couple of posts on here already, know need utilize file_get_contents function this, have bit more advanced need. need able phone call in info submitted user phone call in needed html create email nicer. here of code:
first off, know construction have, within index.php html form, , action="complete.php".
at top of complete.php, have this:
<?php if ($_server["request_method"] == "post") { $evaluator_email = $_post["evaluator_email"]; $teacher_email = $_post["teacher_email"]; $evaluator = $_post["evaluator"]; $teacher = $_post["teacher"]; $date = $_post["date"]; $teacher_body = "hello " . $teacher . ", recently, " . $evaluator . " created teacher evaluation session on " . $date . ". "; $evaluator_body = "hello " . $evaluator . ", evaluation of " . $teacher . " sent " . $teacher_email . ". "; mail($teacher_email , "evaluation" , $teacher_body , "from: $evaluator"); mail($evaluator_email , "evaluation" , $evaluator_body , "from: teacher evaluation tool"); } ?>
which works fine, want able include html. how can create $teacher_body , $evaluator_body equal file contains html write, , still have access php variables such $teacher, $evaluator, $date, etc?
i utilize placeholders in situations this. illustration in html file i'll set things "teacher" , "evaluator" etc. php can along lines of:
$html = file_get_contents("myfilewithplaceholders.htm"); $html = str_replace ( "teacher", $teacher, $html ); $html = str_replace ( "evaluator", $evaluator, $html );
just create sure placeholders unique , should fine.
php html function email
Comments
Post a Comment