<!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,
- PHP drag and drop file upload tutorial using dropzone.js
- Copy file from one directory to other in Php
- PHP Base64 encoding decoding a variable
- macOS - cannot calculate MAC address: Using fd 9 hv_vm_create HV_ERROR [PHP XAMPP]
- Upload Pdf file using PHP Script
- Call PHP function on Button click using jquery ajax
- PHP Code for sending Emails
- PHP header location function not called
- Delete file using PHP code : unlink()
- PHP Warning: Cannot modify header information - headers already sent
- Failed to load resource: net::ERR_CACHE_MISS PHP
- Upload docx file using PHP script
- PHP 301 Redirect Permanently
- PHP Script to Upload Images to Server
- Installing vue.js in Laravel 8
- Remove URL Forward Slash Before Single or Double quotes in php.ini
- How to destroy PHP session()
- PHP Fatal error : Call to a member function bind_param() on a non-object
- 403 forbidden error for Image
More Posts:
- Display Output in Java Console as a Table - Java
- Spotlight Search file path location on Mac OS X Mavericks or Yosemite - Mac-OS-X
- JDK Location in Android Studio - Android-Studio
- How to do calculations in Mac Terminal - MacOS
- How to make a dummy phone call from Android Emulator device - Android
- How to install Zsh shell - HowTos
- SharePoint Online REST API not returning all list items and limit to only 100 rows - SharePoint
- Add X days from today in Command Line - HowTos