This article mainly introduces the method of sending emails by submitting forms in php. It analyzes the techniques of sending emails by operating forms in php, which is very practical. Value, friends in need can refer to it
The example in this article describes how to submit a form to send an email in PHP. Share it with everyone for your reference. The details are as follows:
Save the following html code to: email.html file
?
3 4
5
6
|
Mail Form |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | <🎜>if (empty ($_POST['mailto']) ) {<🎜> <🎜>die ( "Recipient is blank! ") ;<🎜> <🎜>}<🎜> <🎜>if (empty ($_POST['$mailsubject']) ){<🎜> <🎜>$mailsubject=" " ;<🎜> <🎜>}<🎜> <🎜>if (empty ($_POST['$mailbody']) ) {<🎜> <🎜>$mailbody=" " ;<🎜> <🎜>}<🎜> <🎜>$result = mail ($mailto, $mailsubject, $mailbody) ;<🎜> <🎜>//send the email<🎜> <🎜>if ($result) {<🎜> <🎜>echo "Email sent successfully!" ;<🎜> <🎜>}else{<🎜> <🎜>echo "Email could not be sent." ;<🎜> <🎜>}<🎜> <🎜>?> |
I hope this article will be helpful to everyone’s PHP programming design.