<!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:
- Read a file and Split using StringTokenizer in Java - Java
- Run DynamoDB Local on Docker Container - Docker
- Python: Fix command not found pip or pip3 on zsh shell - Python
- Fix 0x80070194 Error When Opening Microsoft OneDrive File - Microsoft
- Android ListView turns Black or Flickers while Scrolling - Android
- Enable Dark Mode in Google Search - Google
- How to run Gradle build in offline mode - Gradle
- Python: Access Environment Variables - Python