I'm using a code I found in developphp.com for a newsletter system. But it doesn't show how to send an email to the subscriber for confirmation and an option to opt out. So, How could I send an email to the new subscriber?
<?php
$name = "";
$email = "";
$msg_to_user = "";
if ($_POST['name'] != "") {
include_once "scripts/connect.php";
$name = $_POST['name'];
$email = $_POST['email'];
$sql = mysql_query("SELECT * FROM newsletter WHERE email='$email'");
$numRows = mysql_num_rows($sql);
if (!$email) {
$msg_to_user = '<br /><br /><h4><font color="FF0000">' . $name . ', Please type in your email.</font></h4>';
} else if ($numRows > 0) {
$msg_to_user = '<br /><br /><h4><font color="FF0000">' . $email . ' is already in the system.</font></h4>';
} else {
$sql_insert = mysql_query("INSERT INTO newsletter (name, email, dateTime)
VALUES('$name','$email',now() )") or die (mysql_error());
$msg_to_user = '
<br /><br /><h4><font color="33cc44">' . $name . ', You have been subscribed.</font></h4>
';
$name = "";
$email = "";
}
}
?>