PHP Code for sending Emails

The below code sends an email through PHP code,
<!DOCTYPE unspecified PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>Sending Email using PHP : Code2care Examples</title>
</head>

<body>

<form action="EmailSender.php" method="post">

To : <input name="to" type="text" />

<br/><br/>
Subject : <input name="subject" type="text" />

<br/><br/>
From : <input name="from" type="text" />

<br/><br/>
Body : <textarea name="body" rows="25" cols="100"></textarea>

<input type="submit" value="submit"> 
</form>

</body>
</html>

Below is the PHP file that is called when the form is submitted,


This is not an AI-generated article but is demonstrated by a human on an M1 Mac running macOS Sonoma 14.0.

Please support independent contributors like Code2care by donating a coffee.

Buy me a coffee!

Buy Code2care a Coffee!

Comments & Discussion

Facing issues? Have questions? Post them here! We're happy to help!