Jump to content

Sending automated emails with php HELP PLEASE!


Freid001

Recommended Posts

I have a registration form on my website which the user has to enter there email address into. My php script needs to send a email to the enter email address registered on the from in order to send the user an account activation link. Below is the code I am attempting to do this with but its not working. Any ideas?

 

 


$mail = strtolower(strip_tags ($_POST["Email"]));

$to = '$mail';

$email_message .= " Content \n"; 

if (mail ($to, 'Registration', $email_message , 'From: ' . $name . ' <' . $email . '>')){
   echo "<meta http-equiv='refresh' content='5;url=/pages/register.php?error=18'>"; 
  } else {
  echo("<p>An error has occurred please try again!</p>");
  }

 

 

Thanks for any help! :D

you can use this kind of code to validate your email address.

 

if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
$e = mysqli_real_escape_string ($dbc, $_POST['email']);
} else {
$errors[] =  'Please enter a valid email address!';
}

 

 

use something like this to send email

 

if validation ok... handle your register form.. 


if (isset ( $_POST['submitted']) ) { // if your form submit true

      // u can validate your input data here... like email, password.....


    // if validation ok.. try something like this 

   if ( empy( $errors )) {

      //here u can send your email....

   }

} 

 

Here I used errors array to store error messages from validation process.. then I checked that errors array empty or not to send email.. It is empty mean, your validation process ok... if it is not empty there is a problem in validation process..

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.