PHP - Explain how to mail the content of a form.

Explain how to mail the content of a form.

Below is the code:

The HTML code can call the samplemail.php page and use the POST method to post the data. “POST” in the Method window indicates that the information in the form will be passed to the program processing the form.
<form action=’samplemail.php' method='post'>
Email: <input type='text' name='email'><br>
Mail body: <textarea name='body'></textarea><br>
<input type='submit' value='Send comments'>
</form>
sampleemail.php (1)
<?php
$to = sample@sample.com;
$subject = "Email from Form";
$message = $_REQUEST["body"];
$email = $_REQUEST["email"];

$headers = "From: $email";
mail($to, $subject, $message, $headers);
echo "Thanks for submitting.";

?>

Explain how to mail the content of a form.

The following is the process to mail the content of a form:

- Create a HTML form. Set the action attribute to a php file , say mailcontent.php
- Make sure that from address, to address, subject and message is properly keyed in
- Assign the corresponding form values in variables , say $email, $subject, $message etc.
- Use the function mail() to send the mail of the available values in variables

Example:
mail("receipient@sample.com","Subject:$subject", $message,"From:$email");
PHP - Explain how to send large amounts of emails with php.
Explain how to send large amounts of emails with php - The mail() function of PHP is quite robust for sending bulk emails...
Advantages of PHP
PHP advantages - PHP offers a lot of security mechanisms, Its easy connectivity abilities make it a popular choice of modular programming......
PHP PEAR
PHP PEAR (PHP Extension and Application Repository) is a framework and a distribution system that is used for reusable PHP components.
Post your comment