Jump to content

Recommended Posts

I am busy writing a mail script. What I would like to do is give a confirmation message if the mail was sent successfully, or a generic message if it was unsuccessful.

Here is what my script looks like:

<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
<title>Easy Security</title>

</head>
<body>

<?php
$firstname = $_POST['firstname'];
$surname = $_POST['surname'];
$telephone = $_POST['telephone'];
$cell = $_POST['cell'];
$email = $_POST['mail'];
$subject = $_POST['subject'];
$message = $_POST['message'];
?>
<?
include 'includes/conn_db.php';
$query1 = "INSERT INTO clients (firstname, surname, telephone, cell, mail) VALUES ('$firstname', '$surname', '$telephone', '$cell', '$email')";
$result1 = @mysql_query ($query1);
$query_count = "SELECT * from bulkmail WHERE mail = '$email'";
$result_count = mysql_query($query_count);
$num_records = @mysql_num_rows($result_count);
if ($num_records == 0) {
$query2 = "INSERT INTO bulkmail (firstname, surname, telephone, cell, mail) VALUES ('$firstname', '$surname', '$telephone', '$cell', '$email')";
$result2 = @mysql_query ($query2);
}
?>
<?
$adminmail = "info@it-people.co.za";
?>



<?
// Recipients. You can send it to more than 1 person!
$to = "$adminmail" ; // note the comma

?>
<?
// This is the email subject
$my_subject = "$subject";
?>


<? // Message
$my_message = <<<MESSAGE
First Name: $firstname<br>Surname: $surname<br>Telephone: $telephone<br>Cellphone: $cell<p>$message
MESSAGE;
?>
<?
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: $email";
?>


<?
// And now mail it!
mail($to, $my_subject, $my_message, $headers);
?>


</body>
</html>

Any help will be appreciated

Thanks

Lional

Link to comment
https://forums.phpfreaks.com/topic/3688-help-with-mail-function/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.