Jump to content

Recommended Posts

So for this project im working on I have a newsletter subscription for the website, when a user submits their email address it is sent to the database and as well a "eMail" is sent to the user with a activation link. I wanted this activation link to limit emails being sent to bots, spiders and all that crap thats not done by humans....

 

anyways. so I have used this mail function before and works great, but for some reason the only thing my script is not doing is sending the email and I can't seem to figure out why.

and yes thats why i am here lol... i figured to have a couple other sets of eyes look at my code and see if i missed something.

 

CODE:

<?php
$em = $_POST['em'];
$status = "OK"; // setting the flag to check the status
$msg="";		 // setting the variable for message

 if (!stristr($em,"@") OR !stristr($em,".")) {
	 $msg="Your email address is not correct: ".$em."<BR>";
$status= "NOTOK";
 }
 if($status=="OK"){ // Now the email is valid and we can add to our database
$activation = md5(uniqid(rand(), true));
	 $query=("INSERT INTO nl_subscribe (em,status) VALUES ('$em','$activation')");
	 $result=mysql_query($query);
 // Send the email:
	 $message = ' To activate your account, please click on this link:\n\n';
	 $message .= ' FULL URL HERE activate.php?email=' . urlencode($em) . '&key='.$activation;
	 mail('guber_x@hotmail.com', 'Newsletter Confirmation', $message, 'From: noreply@fightingforyesterday.com');
echo '<center>THANK YOU '.$em.'<br>Thanks for subscribing to our newsletter and any time you can unsubscribe by clicking a link in your newsletter</center>';
 }
 else {echo "<center>$msg </center>";} // this will display the error message if email address is not valid one.
?>

Link to comment
https://forums.phpfreaks.com/topic/270267-php-mail-function-help/
Share on other sites

hmm, i never used that with my other working mail script...

 

i just added the checking script

 

if(mail("guber_x@hotmail.com", "Newsletter Subscribe", $message, "FROM: noreply@fightingforyesterday.com")){
   echo "Mail Sent";
} else {
   echo "Mail Error";
}

 

and when i submit it does say "Mail Sent" but does not show in the email account anywhere.

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.