After finding out that php need to be run through a server and not as a normal .html file, I need to send an email to the "person" to make an appointment.

Here is my code:

                <?php
                    echo "<form method='post' action='mailform.php'>
                    Email: <input name='email' type='text'><br>
                    Subject: <input name='subject' type='text'><br>
                    Message:<br>
                    <textarea name='message' rows='15' cols='40'>
                    </textarea><br>
                    <input type='submit'>
                    </form>";

                    $email = $_REQUEST['email'] ;
                    $subject = $_REQUEST['subject'] ;
                    $message = $_REQUEST['message'] ;
                    if(mail($email, $subject, $message, "From:" . $email))
                    {
                        printf("Email sent.");
                    }
                ?>

But it doesnt send the email. This code is imbedded inside a .html file and I execute it by http://localhost/email.php

No good linking to a file on localhost, we're not connected to your computer!
Unless you are connected to the internet, and have set the SMTP server address in php.ini file, nothing will be sent from 'localhost'

localhost does not have an smtp server, mail() does not work without an smtp server
html filoes do not process php commands, unless you have modified the configuration "addhandler serverparsed"
the php helpscreens at php.net are very good, and include
EDIT: Correct
code samples, would be probably a good idea to view the mail() help page

Yep, as others have said you need to be running some form of mail server. The simplest you could probably do is to run a relay email server and download something like sSMTP.

A relay email server is essentially one which rides on the back of a proper email server. It shall connect to a main server such as one from your ISP, GMail, Yahoo etc. and then send it from there. It is easier and less demanding than running a full blown email server.

read the mail logs, you will find info there:
tail -f /var/log/mail.err or tail -f /var/log/mail.log

if you are on a shared hosting, it should work by default. if you have home/VPS/Dedicated server/pc try setting qualified domain name in /etc/hosts:

[ipaddress] [longname] [shortname]

127.0.0.1 yourdomainname.com yourdomain

more info: http://newexception.com/unable-to-qualify-my-own-domain-name

@dorco read the OP, he said he ran the script on localhost.... his dev server...

whatever, the same answer applies for localhost...

@dorco, read the prior posts, you will learn as well, there is no smtp server on a wamp localhost
no mail server to send mail, => there are no server logs
you cannot the same answer applies
ignorance is not bliss
wrong answers dont help
whatever dont make wrong, right.

Thanks guys, I will set up an smtp then.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.