Need help with PHP mail script
i have created a log in system . in when the user completes the registration process auto reply(auto-reply@domain) generate and sent users email id regarding user name , password (lo gin details). after formal approval admin user will user activation mail log in link. i discussed this others, said problem mail function configuration. didn't needful information a beginner in php scripting. here ataching code.. <?php
but , problem is these work mail accounts my domain only(test@domain). not send of above mentioned details other mail services gmail or yahoo etc.
i have contacted my hosting service said the problem with php mail () function , use php mailer() instead mail().
please give me solution same..
include 'dbc.php';
$err = array();
if($_post['doregister'] == 'register')
{
foreach($_post $key => $value) {
$data[$key] = filter($value);
}
if(empty($data['full_name']) || strlen($data['full_name']) < 4)
{
$err[] = "error - invalid name. please enter atleast 3 or more characters name";
//header("location: register.php?msg=$err");
//exit();
}
// validate user name
if (!isuserid($data['user_name'])) {
$err[] = "error - invalid user name. can contain alphabet, number , underscore.";
//header("location: register.php?msg=$err");
//exit();
}
// validate email
if(!isemail($data['usr_email'])) {
$err[] = "error - invalid email address.";
//header("location: register.php?msg=$err");
//exit();
}
// check user passwords
if (!checkpwd($data['pwd'],$data['pwd2'])) {
$err[] = "error - invalid password or mismatch. enter 5 chars or more";
//header("location: register.php?msg=$err");
//exit();
}
$user_ip = $_server['remote_addr'];
// stores sha1 of password
$sha1pass = pwdhash($data['pwd']);
// automatically collects hostname or domain example.com)
$host = $_server['http_host'];
$host_upper = strtoupper($host);
$path = rtrim(dirname($_server['php_self']), '/\\');
// generates activation code simple 4 digit number
$activ_code = rand(1000,9999);
$usr_email = $data['usr_email'];
$user_name = $data['user_name'];
$rs_duplicate = mysql_query("select count(*) total users user_email='$usr_email' or user_name='$user_name'") or die(mysql_error());
list($total) = mysql_fetch_row($rs_duplicate);
if ($total > 0)
{
$err[] = "error - username/email exists. please try again different username , email.";
}
if(empty($err)) {
$sql_insert = "insert `users`
(`full_name`,`user_email`,`pwd`,`address`,`tel`,`fax`,`website`,`date`,`users_ip`,`activa tion_code`,`country`,`user_name`
)
values
('$data[full_name]','$usr_email','$sha1pass','$data[address]','$data[tel]','$data[fax]',' $data[web]'
,now(),'$user_ip','$activ_code','$data[country]','$user_name'
)
";
mysql_query($sql_insert,$link) or die("insertion failed:" . mysql_error());
$user_id = mysql_insert_id($link);
$md5_id = md5($user_id);
mysql_query("update users set md5_id='$md5_id' id='$user_id'");
// echo "<h3>thank you</h3> received submission.";
if($user_registration) {
$a_link = "
*****activation link*****\n
http://$host$path/activate.php?user=$md5_id&activ_code=$activ_code
";
} else {
$a_link =
"your account *pending approval* , activated administrator.
";
}
$message =
"hello \n
thank registering us. here login details...\n
user id: $user_name
email: $usr_email \n
passwd: $data[pwd] \n
$a_link
thank you
administrator
$host_upper
______________________________________________________
this automated response.
***do not respond email****
";
mail($usr_email, "login details", $message,
"from: \"member registration\" <auto-reply@$host>\r\n" .
"x-mailer: php/" . phpversion());
header("location: thankyou.php");
exit();
}
}
?>
More discussions in Develop server-side applications in Dreamweaver
adobe
Comments
Post a Comment