lional Posted February 27, 2006 Share Posted February 27, 2006 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 = <<<MESSAGEFirst Name: $firstname<br>Surname: $surname<br>Telephone: $telephone<br>Cellphone: $cell<p>$messageMESSAGE;?><? $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 appreciatedThanksLional Quote Link to comment https://forums.phpfreaks.com/topic/3688-help-with-mail-function/ Share on other sites More sharing options...
php_b34st Posted February 27, 2006 Share Posted February 27, 2006 Try this[code]if (mail($to, $my_subject, $my_message, $headers)) { echo 'Email sent successfully'; } else { echo 'Could not send email.'; }[/code] Quote Link to comment https://forums.phpfreaks.com/topic/3688-help-with-mail-function/#findComment-12882 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.