我想通過使用我的Gmail帳戶通過郵件向用戶發送激活鏈接。我如何設置它。如何使用Gmail發送電子郵件?我在哪裏輸入密碼?如何通過郵件()使用Gmail發送電子郵件?我在哪裏輸入密碼?
它是古代還是我應該去面向對象的方法。
// secure the password
$passWord = sha1($passWord);
$repeatPass = sha1($repeatPass);
// generate random number
$random =rand(1200345670,9999999999);
//send activation email
$to = $email;
$subject = "Activate your account";
$headers = "From: [email protected]";
$server = "smtp.gmail.com";
$body = "Hello $username,\n\n You registered and need to activate your account. Click the link below or paste it into the URL bar of your browser\n\nhttp://phpacademy.info/tutorials/emailactivation/activate.php?id=$lastid&code=$code\n\nThanks!";
ini_set("SMTP",$server);
if (!mail($to,$subject,$body,$headers))
echo "We couldn't sign you up at this time. Please try again later.";
else
{
// register the user
$queryreg = mysql_query("
INSERT INTO users VALUES ('','$userName','$passWord','$fullName','$date','$random','0','$email')
");
$lastid = mysql_insert_id();
die ("You have been registered. <a href='login.php'>Click here</a> to return to the login page.");
echo "Successfully Registered";
}
你可以做到這一點,沒有任何其他資源。 –
是的,但它使用smtp驗證沒有tls,所以它是不安全的,我不會推薦它。如果您使用本地smtp不帶身份驗證發送郵件很有用,但否則我不會使用它。 – mata