Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 无法通过电子邮件发送注册确认电子邮件_Php_Email_Registration - Fatal编程技术网

Php 无法通过电子邮件发送注册确认电子邮件

Php 无法通过电子邮件发送注册确认电子邮件,php,email,registration,Php,Email,Registration,我已经设置了需要电子邮件验证的用户注册表。但是,代码无法生成电子邮件 连接文件: $host="xxxx"; $dbname="xxxx"; $dbuser="xxxx"; $dbpassword="xxxx"; $con = mysqli_connect($host,$dbuser,$dbpassword,$dbname); $website_url="http://www.xxxx/email_activation/"; $sender_email="xxxx@yahoo.com";

我已经设置了需要电子邮件验证的用户注册表。但是,代码无法生成电子邮件
连接文件:

$host="xxxx"; 
$dbname="xxxx";
$dbuser="xxxx";
$dbpassword="xxxx";
$con = mysqli_connect($host,$dbuser,$dbpassword,$dbname); 
$website_url="http://www.xxxx/email_activation/";
$sender_email="xxxx@yahoo.com";
send_mail.php

function send_mail($to,$subject,$body)
{
require 'class.phpmailer.php';
$from       = "from@yourwebsite.com";
$mail       = new PHPMailer();
$mail->IsSMTP(true);            // use SMTP
$mail->IsHTML(true);
$mail->SMTPAuth   = true;                  // enable SMTP authentication  
$mail->Host       = "tls://smtp.mail.yahoo.com"; // SMTP host  
$mail->Port       =  25;                    // set the SMTP port  
$mail->Username   = "xxxx@yahoo.com";  // SMTP  username   
$mail->Password   = "xxxx";  // SMTP password  
$mail->SetFrom($from, 'From Name');  
$mail->AddReplyTo($from,'From Name');  
$mail->Subject    = $subject;  
$mail->MsgHTML($body);  
$address = $to;  
$mail->AddAddress($address, $to);  
$mail->Send();  
}  
注册文件代码:

$activation = md5(uniqid(rand(), true));  
include 'send_mail.php';  
$message = " To activate your account, please click on this link: \n\n ";  
$message .= $website_url . '/activate.php?email=' .urlencode($sender_email) .  
"&key=$activation";  
mail($email_address, 'Registeration Confirmation', $message, 'From:' .$sender_email);

您显示了一个
函数send\u mail()
,但您使用的是标准的php
mail()
函数吗?我看不出这3个代码示例是如何连接的。没有错误消息,唯一的错误是没有发送确认电子邮件。我是php新手,我遵循了博客中列出的步骤。你说得对,函数没有在任何地方调用。我应该在寄存器文件代码中的include语句之后添加函数吗?