Click here to Skip to main content
15,892,839 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
hello, i want to send confirmation code in email through mail() function,but code did not work..
plz help me.
CODE IS:
PHP
if(!empty($result))
{
$to="someone@domain.com";;
$subject="Your confirmation link here";
$message="Your Comfirmation link";
$message.=" Click on this link to activate your account ";
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

$sentmail = mail($to,$subject,$message,$headers);
}
else
 {
echo "Email Address Is Not In Database!";
}
if($sentmail)
{
echo "Your Confirmation link Has Been Sent To Your Email Address.";
}
else
 {
echo "Error! Cannot send Confirmation link ";
}
Posted
Comments
Smithers-Jones 7-Oct-10 5:26am    
Sigh... And WHAT exactly did not work? "code did not work" is a little bit vague, don't you think so? You have to explain a bit more and post your error message, if you expect people to help you.
Sunny s 7-Oct-10 5:40am    
It did not send the mail to email address.
output is: echo "Error! Cannot send Confirmation link ";
ely_bob 7-Oct-10 14:35pm    
Wouldn't it be easier to just put all the headers/messages into the same line.. just a thought.

Also i hope your not using the actual email:"someone@domain.com".. because that won't work... =P
Sunny s 8-Oct-10 2:13am    
Would you like to share about smtp_port?
Uday P.Singh 6-Jul-11 6:42am    
have you set your smtp configuration in your php.ini file?

you can set SMTP configuration by writing this in your php script:

MIDL
ini_set("SMTP", "domainname.com"); 
ini_set('sendmail_from', "yourname@domain.com");


hope it helps :)
 
Share this answer
 
v2
what error message is displayed when you run the script?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900