Lee-Bartlett Posted November 17, 2008 Share Posted November 17, 2008 Ok all im trying to do is a simple mail script but im not sure how completly, atm i have the code below, that is on a html page which re directs in about 3 seconds. where am i going wrong ? <?php $to = "leebartlett18@googlemail.com"; $subject = "Hi!"; $body = "Hi,\n\nHow are you?"; if (mail($to, $subject, $body)) { echo("<p>Message</p>"); } else { echo("<p>Message delivery failed...</p>"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/133126-mail-script/ Share on other sites More sharing options...
premiso Posted November 17, 2008 Share Posted November 17, 2008 The first spot I see is that you check mail for true/false this indicator is buggy and often returns the wrong result. Also I do not see the redirection done in the code... Also you are not using Mail Headers, mail has examples of them, although they are not needed if they are not there alot of email apps will block them as spam. Quote Link to comment https://forums.phpfreaks.com/topic/133126-mail-script/#findComment-692302 Share on other sites More sharing options...
Lee-Bartlett Posted November 17, 2008 Author Share Posted November 17, 2008 This is the whole code, first im putting stuff into my db, then i want a mail to go me, telling me somthing new has been entered. this is all my code. Im new to mailing so got no clue how <?php session_start(); ?> <?php require_once('db_connection.php'); ?> <?php include_once ("securimage/securimage.php"); $securimage = new Securimage(); if ($securimage->check($_POST['captcha_code']) == false) { // the code was incorrect // handle the error accordingly with your other error checking // or you can do something really basic like this ?> <a href="http://www.nexodom.com/website/userform.php">The code you entered was incorrect. Go back and try again.</a> <?php die(''); } $sql="INSERT INTO tblbasicform (name, email, buissnes_name, location, ct, website, telephone, longitude, latitude, type, approve) VALUES ('$_POST[name]','$_POST[email]','$_POST[buissnes_name]','$_POST[location]','$_POST[ct]','$_POST[website]','$_POST[telephone]','$_POST[longitude]', '$_POST[latitude]','$_POST[type]','$_POST[approve]')"; if (!mysql_query($sql,$connect)) { die('Error: ' . mysql_error()); } ?> <?php $to = "leebartlett18@googlemail.com"; $subject = "Hi!"; $body = "Hi,\n\nHow are you?"; if (mail($to, $subject, $body)) { echo("<p>Message</p>"); } else { echo("<p>Message delivery failed...</p>"); } ?> <html> <head> <meta http-equiv="refresh" content="2;url=http://nexodom.com/website/index.php"> <title></title> Quote Link to comment https://forums.phpfreaks.com/topic/133126-mail-script/#findComment-692303 Share on other sites More sharing options...
daveoffy Posted November 18, 2008 Share Posted November 18, 2008 <?php // Contact subject $subject ="Hi"; // Details $message="$Hi,\n\nHow are you?"; // Enter your email address $to ='leebartlett18@googlemail.com'; $send_contact=mail($to,$subject,$message); // Check, if message sent to your email // display message "We've recived your information" if($send_contact){ echo "We've recived your message"; } else { echo "Message delivery failed..."; } ?> put this where all the mail send stuff is. Modify as you need. Quote Link to comment https://forums.phpfreaks.com/topic/133126-mail-script/#findComment-692502 Share on other sites More sharing options...
trq Posted November 18, 2008 Share Posted November 18, 2008 The first spot I see is that you check mail for true/false this indicator is buggy and often returns the wrong result. This statement is completely untrue. mail returns true if the mail was accepted (by the mail server) for delivery (always) and false otherwise (always). However, just becuase the mail server accepts it does not meen it will always reach its destination. Nothing php can do about that, its not php's responsability to actually send the mail. Quote Link to comment https://forums.phpfreaks.com/topic/133126-mail-script/#findComment-692511 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.