Freid001 Posted May 26, 2012 Share Posted May 26, 2012 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! Quote Link to comment https://forums.phpfreaks.com/topic/263173-sending-automated-emails-with-php-help-please/ Share on other sites More sharing options...
Freid001 Posted May 26, 2012 Author Share Posted May 26, 2012 Is it even possible to do this? Quote Link to comment https://forums.phpfreaks.com/topic/263173-sending-automated-emails-with-php-help-please/#findComment-1348794 Share on other sites More sharing options...
thara Posted May 26, 2012 Share Posted May 26, 2012 Do u need to send an email with an account activation link? Quote Link to comment https://forums.phpfreaks.com/topic/263173-sending-automated-emails-with-php-help-please/#findComment-1348795 Share on other sites More sharing options...
Freid001 Posted May 26, 2012 Author Share Posted May 26, 2012 I need to make sure that there email address is valid. So yes. Quote Link to comment https://forums.phpfreaks.com/topic/263173-sending-automated-emails-with-php-help-please/#findComment-1348798 Share on other sites More sharing options...
Pikachu2000 Posted May 26, 2012 Share Posted May 26, 2012 Exactly how is it "not working"? Quote Link to comment https://forums.phpfreaks.com/topic/263173-sending-automated-emails-with-php-help-please/#findComment-1348799 Share on other sites More sharing options...
Freid001 Posted May 26, 2012 Author Share Posted May 26, 2012 Well it says that It sends the email but then I check my inbox and there's no email I have checked the span and junk folders to but no email ? Quote Link to comment https://forums.phpfreaks.com/topic/263173-sending-automated-emails-with-php-help-please/#findComment-1348800 Share on other sites More sharing options...
thara Posted May 26, 2012 Share Posted May 26, 2012 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.. Quote Link to comment https://forums.phpfreaks.com/topic/263173-sending-automated-emails-with-php-help-please/#findComment-1348801 Share on other sites More sharing options...
Freid001 Posted May 26, 2012 Author Share Posted May 26, 2012 Ok ive worked out that with out a URL link in the email content it send the email but with a URL link in the content it does not send a email. wired? Any one know why this is? Quote Link to comment https://forums.phpfreaks.com/topic/263173-sending-automated-emails-with-php-help-please/#findComment-1348802 Share on other sites More sharing options...
Freid001 Posted May 26, 2012 Author Share Posted May 26, 2012 Does anyone know how to send a URL in a php email? Quote Link to comment https://forums.phpfreaks.com/topic/263173-sending-automated-emails-with-php-help-please/#findComment-1348806 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.