这是我在这里的第一个问题,所以感谢大家阅读本文。我正在关注 PHP 学院关于注册和登录部分的教程。
我正在使用亚马逊的 EC2 服务(到目前为止效果很好),我想知道如何更改我的代码以使用我的 SMTP 服务器(来自另一个网络主机)发送我的激活电子邮件。请参阅下面的代码。如果您有任何问题,请告诉我。再说一次,这是我的第一次。
谢谢您的帮助。
亲切的问候,恩里科·尤斯曼
General.php 文件:
function email($to, $ubject, $body) {
mail($to, $subject, $body, 'From: activate@proxico.nl');}
用户.php 文件:
function register_user($register_data) {
array_walk($register_data, 'array_sanitize');
$register_data['password'] = md5($register_data['password']);
$fields = '`' . implode('`, `', array_keys($register_data)) . '`';
$data = '\'' . implode('\', \'', $register_data) . '\'';
mysql_query("INSERT INTO `users` ($fields) VALUES ($data)");
email($register_data['email'], 'Activate your account',"Hello " . $register_data['first_name'] . ",\n\nYou need to activate your account, so use the link below:\n\nhttp://ec2-54-229-189-136.eu-west-1.compute.amazonaws.com/activate.php?email=" . $register_data['email'] . "&email_code=" . $register_data['email_code'] . " \n\n - Proxico");
}
Register.php 文件:
if (isset($_GET['success']) && empty($_GET['success'])) {
echo 'You\'ve been registered successfully! Please check your email for an activation link. Didn\'t get an email? Click here to resend.';
} else {
if (empty($_POST) === false && empty($errors) === true) {
$register_data = array(
'username' => $_POST['username'],
'password' => $_POST['password'],
'first_name' => $_POST['first_name'],
'last_name' => $_POST['last_name'],
'email' => $_POST['email'],
'email_code' => md5($_POST['username'] + microtime())
);
register_user($register_data);
header('Location: register.php?success');
exit();
} else if (empty($errors) === false) {
echo output_errors($errors);
// output register errors
}