PHP邮件-电子邮件发送

PHP邮件-电子邮件发送,php,Php,我想向试图注册的用户发送确认邮件。Iam使用PHP邮件发送程序发送邮件。这是我的密码: require_once("PHPMailer/class.phpmailer.php"); $mail = new PHPMailer(); $mail->IsSMTP(); $mail->Host = "localhost"; $mail->SMTPAuth = true;// turn on SMTP authentic

我想向试图注册的用户发送确认邮件。Iam使用PHP邮件发送程序发送邮件。这是我的密码:

require_once("PHPMailer/class.phpmailer.php");

        $mail = new PHPMailer();
        $mail->IsSMTP();
        $mail->Host = "localhost";
        $mail->SMTPAuth = true;// turn on SMTP authentication
        $mail->Username = "root";// SMTP username
        $mail->Password = "";// SMTP password
        $mail->SetLanguage("en","PHPMailer/language");

        //compose mail
        $mail->From = "admin@localhost.com";
        $mail->FromName = "Cinema Admin";
        $mail->AddAddress($_POST['email']);
        $mail->AddReplyTo("admin@localhost.com", "Cinema Admin");
        $mail->Subject = 'Your confirmation link here';
        $mail->Body = "Your confirmation link\r\n";
        $mail->Body .= "Click on this link to activate your sccount\r\n";
        $mail->Body .= "http://localhost/user.login_plugin/confirm.php?passkey=$confirm_code"; 

        //send mail
        if (!$mail->Send())
        {
            echo "Message was not sent <p>";
            echo "Mailer Error: " . $mail->ErrorInfo;
            exit;
        }

        echo "Message has been sent";
有谁能建议我从localhost向注册用户的emailid发送邮件。 我搜索了一些关于stack overflow中结束电子邮件的标题,但从任何帖子中都找不到任何解决方案


提前感谢您

您能尝试删除smtp部分吗?根据您的评论,您没有邮件服务器设置

    $mail = new PHPMailer();

    $mail->SetLanguage("en","PHPMailer/language"); // remove smtp things

您必须需要SMTP详细信息才能使用SMTP发送电子邮件,例如,如果您想使用gmail设置SMTP

    $mail->IsSMTP(); // telling the class to use SMTP
    $mail->SMTPAuth   = true;         // enable SMTP authentication
    $mail->SMTPSecure = "tls";        // sets the prefix to the servier
    $mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
    $mail->Port       = 587;                   // set the SMTP port for the GMAIL server
    $mail->Username   = "yourusername@gmail.com";  // GMAIL username
    $mail->Password   = "yourpassword";            // GMAIL password
如果不想使用SMTP,可以调用默认邮件功能

$mail->IsMail(); //Sets Mailer to send message using PHP mail() function.

请检查您的smtp身份验证,或者不要使用smtp。请告诉我如何使用Windows 7检查smtp身份验证,Iam。您是否在本地设置了邮件服务器?否。。我没有任何邮件服务器的设置。你能帮我怎么做吗?Iam使用WINDOWS 7是否有从本地主机发送邮件的解决方案。我在stack overflow中看到过很多帖子,没有人对关于发送邮件的答案感到满意。我按照你的建议删除了所有smtp内容,现在执行时显示:Mailer错误:无法实例化邮件功能。它不能仅是gmail,它可以是gmail、yahoo或hotmail等任何内容。,应该从我的本地主机向用户注册的电子邮件发送电子邮件。
$mail->IsMail(); //Sets Mailer to send message using PHP mail() function.