Jump to content

Recommended Posts

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>");
}
?>

Link to comment
https://forums.phpfreaks.com/topic/133126-mail-script/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/133126-mail-script/#findComment-692302
Share on other sites

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>

Link to comment
https://forums.phpfreaks.com/topic/133126-mail-script/#findComment-692303
Share on other sites

<?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.

Link to comment
https://forums.phpfreaks.com/topic/133126-mail-script/#findComment-692502
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/133126-mail-script/#findComment-692511
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.