Hi,
You just need to use the php mailer functionality. I use php frameworks, my preferred is Zend Framework. You can use the Zend_Mail class standalone, using just a few lines of code:
mailer.php
Code: Select all
<?php
require_once('Zend/Mail.php');
$mail = new Zend_Mail();
$mail->setBodyText("Your message");
$mail->setBodyHtml("Your HTML message");
$mail->setFrom('you@youraddress.co.uk', strip_tags($_POST['name']));
$mail->addTo(strip_tags($_POST['mail']), strip_tags($_POST['name']));
$mail->setSubject("Email title");
$mail->send();
The code implies that the ZF library folder is in your include path, or relative to the running script (not wise to have it publically accessible, though). You should also validate and filter the input from the form before sending it out, and have some safeguards to prevent spamming and robots. You need the HTML form to submit to the above script like this:
send.htm
Code: Select all
<form name="form1" method="post" action="mailer.php">
Your name: <input type="text" name="name" id="name" /><br />
Friends email: <input type="text" name="mail" id="mail" />
</form>
It's a really simple example, and that HTML isn't very semantic, but it should do the job.
Hope that was helpful.