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: 10850 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: Mail server+functionality+php+for sending mail receiving mails  php function sending mails on specific date  php mail function many e-mails  mail function php send html mails  php mail function not sending  php mail function sending html  mail() function in php for sending files  sending pictures with php mail function  sending mail function PHP windows  sending html with php mail function  sending mail function form php  mail function not sending results  function mail php sending from server  tutorials on sending form data through php mail function  php sending mails  "sending mails in php"  sending mails from php and mysql  method for sending mails in php  functions for sending mails with php  problems sending receiving e-mails