<!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,
<?php
$mailTo = $_POST['to']."\r\n";
$mailSubject = $_POST['subject']."\r\n";
$mailBody = $_POST['body']."\r\n";
$mailHeaders = "From: ".$_POST['from']."\r\n";
$mailHeaders .= "Reply-To: emailID@yourdomain.com \r\n";
$mailHeaders .= "Return-Path: emailID@yourdomain.com \r\n";
$mailHeaders .= "X-Mailer: PHP5 \r\n";
$mailHeaders .= 'MIME-Version: 1.0' . "\r\n";
$mailHeaders .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
//Send Email Function
mail($mailTo,$mailSubject,$mailBody,$mailHeaders);
?>
More Posts related to PHP,
- Delete file using PHP code : unlink()
- PHP header location function not called
- 403 forbidden error for Image
- Call PHP function on Button click using jquery ajax
- How to Pretty Print JSON in PHP
- Step-by-Step Guide: How to Fix - Error Establishing a Database Connection in WordPress
- PHP Base64 encoding decoding a variable
- PHP Fatal error : Call to a member function bind_param() on a non-object
- PHP.ini: How to Remove URL Forward Slash Before Single or Double Quotes
- PHP drag and drop file upload tutorial using dropzone.js
- Upload Pdf file using PHP Script
- PHP Warning: Cannot modify header information - headers already sent
- macOS - cannot calculate MAC address: Using fd 9 hv_vm_create HV_ERROR [PHP XAMPP]
- PHP Code for sending Emails
- How to destroy PHP session()
- Installing vue.js in Laravel 8
- PHP 301 Redirect Permanently
- Upload docx file using PHP script
- Save current timestamp in MySQL using PHP mysqi binding
- Copy file from one directory to other in Php
- Failed to load resource: net::ERR_CACHE_MISS PHP
- PHP Script to Upload Images to Server
More Posts:
- Fix mySQL Error Cant connect to local MySQL server through socket /var/run/mysqld/mysqld.sock ERROR 2002 HY000 - MySQL
- Is Roblox available on the Mac App Store? - MacOS
- Fix: Error code: 0x204 Microsoft Remote Desktop - Unable to connect the remote PC. - Windows
- Add Emojis and GIFs using Windows 10 or 11 PC Keyboard - Windows-11
- Find MAC address of your laptop device - HowTos
- How to delete SharePoint Online List Item using REST API - SharePoint
- How to set CSS background-Image Property - CSS
- How to hide or disable iOS 14 App Library on iPhone? - Apple