Home >Backend Development >PHP Tutorial >How to submit form and send email in php_PHP tutorial
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.