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 = "[email protected]";?><?// 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 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] Link to comment https://forums.phpfreaks.com/topic/3688-help-with-mail-function/#findComment-12882 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.