即時通訊使用wamp,我想從一個教程在YouTube上測試一個電子郵件功能,但它不會發送,我得到的所有代碼都是正確的,它發送了您的電子郵件的消息已經送走了。我甚至改變了php.ini文件 SMTP = smtp.gmail.com sendmail_from = [email protected] 任何建議我如何發送電子郵件從本地主機到我的gmail
如果u能可以ü給我寫一封電子郵件功能,這裏是我的 這是一個忘記密碼的事情我做即時通訊試圖向用戶發送電子郵件的新密碼
<?php
if (isset($_GET['success']) === true && empty($_GET['success']) === true) {
?>
<p>Thanks, we've emailed you.</p>
<?php
} else {
$mode_allowed = array('email', 'password');
if (isset($_GET['mode']) === true && in_array($_GET['mode'], $mode_allowed) === true) {
if (isset($_POST['email']) === true && empty($_POST['email']) === false) {
if (user_exists($_POST['email']) === true) {
recover($_GET['mode'], $_POST['email']);
header('Location: recover.php?success');
exit();
} else {
echo '<p>Ooops, we couldn\'t find that email address</p>';
}
}
?>
function recover($mode, $email) {
$mode = sanitize($mode);
$email = sanitize($email);
$user_data = user_data(user_id_from_email($email),'user_id', 'first_name', 'username');
if ($mode == 'username') {
email($email, 'Your username', "Hello " . $user_data['first_name'] . ",\n\nYour username is: ". $user_data['username'] . "\n\n-phpacademy");
} else if ($mode == 'password') {
$generated_password = substr(md5(rand(999, 999999)), 0, 8);
change_password($user_data['user_id'], $generated_password);
email($email, 'Your password recovery', "Hello " . $user_data['first_name'] . ",\n\nYour pasword is: ". $generated_password . "\n\n-phpacademy");
}
}
function email($to, $subject, $body, $headers) {
mail($to, $subject, $body, $headers);
}
如果您只是想測試從您的代碼發送的電子郵件,則可以始終使用[DevNullSMTP](http://www.aboutmyip.com/AboutMyXApp/DevNullSmtp.jsp)等工具來發送電子郵件,郵件在您的本地機器上。 – ajp15243