Networking, Programming and Graphics Tutorials

Sending e-mails with PHP mail() function [1/3]

Type: Code Networking, Programming and Graphics Tutorials
Sending e-mails with PHP mail() function
Level: Beginner Networking, Programming and Graphics Tutorials 
Sending e-mails with PHP mail() function
Date: 2006-Dec-05
Sending e-mails with PHP mail() function
Visited: 12185 times
Sending e-mails with PHP mail() function
Rating: Sending e-mails with PHP mail() function
Sending e-mails with PHP mail() function
Author: Ivory Morhuld

You have seen html form whose send e-mails based on content entered in the form and now you want the same form on your web site. Ok, no problem.

Let's start with html file which containing the form where user writes his message and send by pressing the [Send] button.

Please note that we have one input field named "send" with value parameter set to 1. This field we will use later when sending form to server to check that the form is truly sent.

Also in our example we using POST method for sending the data and for action of form we use the same file with form - $_SERVER['PHP_SELF']

<html>
<head>
<title>Sending e-mails with PHP mail() function</title>
</head>
<body>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    <input type="text" name="from_name">
    <input type="text" name="from_email">
    <textarea name="message"></text>
    <input type="hidden" name="Send" value="1">
    <input type="submit" value="Send">
</form>
</body>
</html>
You have to know that when in your php.ini register_globals = Off and you receiving data with POST method you have to use $_POST['var_name'] instead $var_name!

<?php
$send
=$_POST['send'];
$from_name=$_POST['from_name'];
$from_email=$_POST['from_email'];
$message=$_POST['message'];
?>
Networking, Programming and Graphics Tutorials - Sending e-mails with PHP mail() function [1/3] - Networking, Programming and Graphics Tutorials

Need a specific tutorial? Do not hesitate and submit a request!
Related Tags: problem sending mails with php mail function  sending html mails with mail function on php  mail() function+not receiving mails  How to send many mails in one mail function in php  mail php function not sending mail  php mail function not sending  mail() function not sending  sending picture with mail() function  mail function sending image  php mail sending function with image