开发者

PHP - Please help me to complete my project

How to link the code to smtp. And how to link smtp to my localhost. and how to substitute this with my ISP details and the email id to the email id which i use for sending.

Below is the Code for your reference

<?php

ini_set('display_errors',1);
error_reporting(E_ALL|E_STRICT);

include('config.php');

// table name
$tbl_name="temp_members_db";

// Random confirmation code
$confirm_code=md5(uniqid(rand()));

// values sent from form
$name=$_POST['name'];
$email=$_POST['email'];
$country=$_POST['country'];

// Insert data into database
$sql="INSERT INTO $tbl_name(confirm_code, name, email, password, country)VALUES('$confirm_code', '$name', '$email', '$password', '$country')";
$result=mysql_query($sql);

// if suceesfully inserted data into database, send confirmation link to email
if($result){

//开发者_如何学Go ---------------- SEND MAIL FORM ----------------

// send e-mail to ...
$to=$email;

// Your subject
$subject="Your confirmation link here";

// From
$header="FROM: your email";

// Your message
$message="Your Comfirmation link \r\n";
$message.="Click on this link to activate your account \r\n";
//$message.="http://www.yourweb.com/confirmation.php?passkey=$confirm_code";
$message.="http://localhost/confirmation.php?passkey=$confirm_code";

// send email   
$sentmail = mail($to,$subject,$message,$header);

}

// if not found
else {
echo "Not found your email in our database";
}

// if your email succesfully sent
if($sentmail){
echo "Your Confirmation link Has Been Sent To Your Email Address.";
}
else {
echo "Cannot send Confirmation link to your e-mail address";
}

?>


If you can't use mail() - it's not really clear from your question what the problem is - consider using an alternative library like SwiftMailer. Here is a quick example for sending a message through SMTP.


You can also use PEAR. Look at following articles:

  • How to Send Email from a PHP Script Using SMTP Authentication
  • PHP Send Email Using Authenticated SMTP Mail Server In Real Time

EDIT:

  • PHP PEAR Installation
  • Use PHP Pear with Ubuntu
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜