I’m creating a user registration form and after they fill in all the information and submit the form all of the data goes in my database table. After a successful registration A confirmation email is sent to the users email address which is supplied by the user in the registration form. But the email is not sending.I am getting the error message shown below:
Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port
25, verify your "SMTP" and "smtp_port" setting in
php.ini or use ini_set() in D:\wamp\www\boobloom\site\class.Utility.inc.php on line 25
Registration Successful.
This is the function I am using in my registration form:
if(mysql_query($insert_query)){
Utility::sendRegConfirmEmail(mysql_insert_id());
echo $message = "Registration Successful.";
}else{
echo $message = "Registration not Successful.";
}
and:
static function sendRegConfirmEmail($id){
$query = "SELECT * FROM users WHERE id = '".$id."'";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_assoc($result);
$to = $row['email'];
$confirmationcode = $row['confirmation_code'];
$tVar = time();
$confirmLink = HTTP_PATH.'registrationConfirm/'.md5($tVar).'/'.$to.'/'.$confirmationcode.'/'.md5($to);
// to fetch the email template
$queryET = "SELECT * FROM emailtemplates WHERE type = 'registration_confirmation'";
$resultET = mysql_query($queryET) or die(mysql_error());
$rowET = mysql_fetch_assoc($resultET);
$subject = $rowET['subject'];
$toRepArray = array('[!Name!]','[!email!]','[!PASSWORD!]','[!activation_code!]','[!Link!]');
$fromRepArray = array($to,$to,$row['password'],$confirmationcode,$confirmLink);
$message = str_replace($toRepArray,$fromRepArray,$rowET['message']);
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: boobloom.com <".SITE_MAIL.">\r\n";
mail($to, $subject, $message, $headers);
}
This error is from your smtp setup and not your code. You should verify that your smtp is properly set up.
Try using
To get your SMTP details.
Check your php.ini
It should be in this kinda format