1

I have a PHP website wherein users fill in their registration details and an email goes to them with a link to activate their account. The problem is that sometimes the activation email goes and sometimes it doesnt. I want to make sure that after every registration the activation link email goes to the subscriber to activate his account. Right now there is no way to track this until the user tells us. To solve this I also want to get a copy of that email on my email address so that it acts as additional confirmation.

Here is the current code and any help to solve this would be highly appreciated -

$qq = "select * from quiz_tmpreg where id='".$_SESSION['uid']."'";         
$ex = mysqli_query($dbcon, $qq);    
$trp = mysqli_fetch_array($ex);   
$ToEmail = $trp['email'];  
$EmailSubject = "Registration Details"; 
$mailheader = "From: "."orders@company.com"."\r\n";   
$mailheader .= "Reply-To: ".'orders@company.com'."\r\n";    
$mailheader .= "Content-type: text/html; charset=utf-8\r\n";                                                     
$MESSAGE_BODY  = " User Name :- " .$trp['uname']. ",<br>";    
$MESSAGE_BODY .= " Password :- " .$trp['pass']. ",<br>";    
$MESSAGE_BODY .= " Your Unique ID :- " .$_SESSION['uniq_id']. ",<br>";    
$MESSAGE_BODY .= " Activation Link :- http://company.com/confirm.php?    encrypt=".$_SESSION['uid']."<br>";    

mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader);
unset($_SESSION['uid']);
RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
Abhinav
  • 11
  • 1
  • You can make a link to re-send the email available to the user. Sometimes it's not even your fault but the user's mail that can block it for spam etc – al'ein Aug 29 '15 at 19:37
  • Thanks Aedix. Thats a good hint. Could you help provide the code to re-send the activation link? This can be useful if the user doesnt activate the account within 48 hours. – Abhinav Aug 29 '15 at 19:59

1 Answers1

0
  1. you can test the result of mail() for any errors. php.net/mail()
  2. as usual, you should present a hint after user's registration, tell him to check the inbox and his spam folder, and to contact you if they didn't receive an email.
  3. you can use timetstamp of registration date to check if any users did sign up but didn't check back via the confirmation link after a certain time. if that happens a lot you can investigate more on that
Diego 72
  • 61
  • 7