我正在尝试提交注册表单,提交后会发送确认链接进行验证。我正在使用php邮件功能。它回应说邮件已经发送但在等待几分钟后没有发送电子邮件。我将我的localhost配置为localhost:8080并使用3307作为我的数据库,一切都很好,因为它在我的数据库中提供。我的问题是没有发送电子邮件。你能告诉我有什么问题或我需要做些什么来使这项工作因为我只是一个初学者。感谢:)
这是我的代码:
<?php
include('config.php');
// table name
$tbl_name='temp_members_db';
// Random confirmation code
$confirm_code=md5(uniqid(rand()));
// values sent from form
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$email=$_POST['email'];
$pword=$_POST['pword'];
$number=$_POST['number'];
$house=$_POST['house'];
$street=$_POST['street'];
$city=$_POST['city'];
// Insert data into database
$sql="INSERT INTO $tbl_name(confirm_code, firstname, lastname, email, password, number, house1, street1, city)VALUES('$confirm_code', '$firstname', '$lastname', '$email', '$pword', '$number', '$house', '$street', '$city')";
$result=mysql_query($sql);
// if suceesfully inserted data into database, send confirmation link to email
if($result){
// ---------------- SEND MAIL FORM ----------------
// send e-mail to ...
$to=$email;
// Your subject
$subject="Your confirmation link here";
// From
$header="from: Athan Motorcycles <nickcuenza@gmail.com>";
// Your message
$message="Your Confirmation link \r\n";
$message.="Click on this link to activate your account \r\n";
$message.="http://www.yourweb.com/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";
}
?>
所以来自POP3的消息说
Connection from 127.0.0.1, Sat Dec 14 01:58:22 2013
User root, (2) 0 messages, 0 bytes
1 sec. elapsed, connection closed Sat Dec 14 01:58:23 2013
Connection from 127.0.0.1, Sat Dec 14 01:58:54 2013
Connection from 127.0.0.1, Sat Dec 14 01:59:08 2013
User root, (2) 0 messages, 0 bytes
1 sec. elapsed, connection closed Sat Dec 14 01:59:09 2013
Connection from 127.0.0.1, Sat Dec 14 01:59:40 2013
User root, (2) 0 messages, 0 bytes
1 sec. elapsed, connection closed Sat Dec 14 01:59:41 2013
Connection from 127.0.0.1, Sat Dec 14 02:00:12 2013
User root, (2) 0 messages, 0 bytes
1 sec. elapsed, connection closed Sat Dec 14 02:00:13 2013
Connection from 127.0.0.1, Sat Dec 14 02:00:44 2013
User root, (2) 0 messages, 0 bytes
1 sec. elapsed, connection closed Sat Dec 14 02:00:45 2013
Connection from 127.0.0.1, Sat Dec 14 02:01:16 2013
User root, (2) 0 messages, 0 bytes
1 sec. elapsed, connection closed Sat Dec 14 02:01:17 2013
Connection from 127.0.0.1, Sat Dec 14 02:01:48 2013
User root, (2) 0 messages, 0 bytes
1 sec. elapsed, connection closed Sat Dec 14 02:01:49 2013
Connection from 127.0.0.1, Sat Dec 14 02:02:20 2013
User root, (2) 0 messages, 0 bytes
1 sec. elapsed, connection closed Sat Dec 14 02:02:21 2013
Connection from 127.0.0.1, Sat Dec 14 02:02:52 2013
User root, (2) 0 messages, 0 bytes
1 sec. elapsed, connection closed Sat Dec 14 02:02:53 2013
Connection from 127.0.0.1, Sat Dec 14 02:03:24 2013
User root, (2) 0 messages, 0 bytes
1 sec. elapsed, connection closed Sat Dec 14 02:03:25 2013
Connection from 127.0.0.1, Sat Dec 14 02:03:56 2013
User root, (2) 0 messages, 0 bytes
1 sec. elapsed, connection closed Sat Dec 14 02:03:57 2013
Connection from 127.0.0.1, Sat Dec 14 02:04:28 2013
User root, (2) 0 messages, 0 bytes
1 sec. elapsed, connection closed Sat Dec 14 02:04:29 2013
在检查会话后,它说
01:59:08.609: Connection from 127.0.0.1, Sat Dec 14 01:59:08 2013
01:59:08.609: << +OK <6495609.23560@localhost>, POP3 server ready.<cr><lf>
01:59:09.593: >> USER root<cr><lf>
01:59:09.593: << +OK root is known here.<cr><lf>
01:59:09.593: >> PASS root<cr><lf>
01:59:09.593: << +OK Welcome! 0 messages (0 bytes)<cr><lf>
01:59:09.593: >> STAT<cr><lf>
01:59:09.593: << +OK 0 0<cr><lf>
01:59:09.593: >> QUIT<cr><lf>
01:59:09.593: << +OK localhost Server closing down.<cr><lf>
01:59:09.593: --- Connection closed normally at Sat Dec 14 01:59:09 2013. ---
01:59:09.593: