Networking, Programming and Graphics Tutorials

How to Send Email from a PHP Script [1/3]

Type: Code Networking, Programming and Graphics Tutorials
How to Send Email from a PHP Script
Level: Beginner Networking, Programming and Graphics Tutorials 
How to Send Email from a PHP Script
Date: 2007-Jan-26
How to Send Email from a PHP Script
Visited: 4291 times
How to Send Email from a PHP Script
Rating: How to Send Email from a PHP Script
How to Send Email from a PHP Script
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 - How to Send Email from a PHP Script [1/3] - Networking, Programming and Graphics Tutorials

Need a specific tutorial? Do not hesitate and submit a request!
Related Tags: send email on web php  "PHP how to send email"  "send email from web"  how to send email  plesk send mail php script  email troubleshooting  php email PHP_SELF  cc proxy,how to set up email  php email mysql query  function email($from, $from_name, $to, $message)  new email account microsoft office outlook  unicef email account port number  php mail function to email multiple form fields  Spam, or unsolicited email, is a common abuse of Internet anonymity  send header php  php send headers  php send mail phpself  how to send info by +netowrking  windows xp send ping  windows "send buffer"