亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

我沒有收到郵件

我沒有收到郵件

慕蓋茨4494581 2023-12-04 10:34:45
$to = 'someone.com';$firstname = $_POST["fname"];$lastname = $_POST["fname"];$subject= $_POST["subject"];$email= $_POST["email"];$text= $_POST["message"];$headers = 'MIME-Version: 1.0' . "\r\n";$headers .= "From: " . $email . "\r\n"; // Sender's E-mail$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";這是我的 php 頁面的代碼。你能讓我知道我的代碼有什么問題嗎?感謝您的幫助if (mail($to,$subject,$text,$headers)){  echo "Check Email please";} else{    echo 'failed';}
查看完整描述

1 回答

?
胡說叔叔

TA貢獻1804條經驗 獲得超8個贊

請確保您在頂部添加 Phpmailer 類。


這是一個正常工作的郵件程序文件,將您的憑據放在這里并發送電子郵件。


<!DOCTYPE html>

<html>

<head>

    <title>Php Mailer</title>

    <link rel="stylesheet" type="text/css" href="bootstrap.min.css">

</head>

<body>

        <?php 

    // require 'PHPMailerAutoload.php';


        require("PHPMailer-master/src/PHPMailer.php");

        require("PHPMailer-master/src/SMTP.php");

        require("PHPMailer-master/src/Exception.php");



        $mail = new PHPMailer\PHPMailer\PHPMailer();

        $SendMailTo = "[email protected]";


        $mail->SMTPDebug = 0;                       


        $mail->isSMTP();                                      // Set mailer to use SMTP

        $mail->Host = 'smtp.gmail.com;';  // Specify main and backup SMTP servers

        $mail->SMTPAuth = true;                               // Enable SMTP authentication

        $mail->Username = "[email protected]";                 // SMTP username

        $mail->Password = "your_user_Password";                           // SMTP password

        // $mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted

        $mail->Port = 587;                                    // TCP port to connect to


        $mail->setFrom("[email protected]");

        $mail->addAddress($SendMailTo);     // Add a recipient             // Name is optional

        $mail->addReplyTo("[email protected]");


        // $mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments

        // $mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name

        $mail->isHTML(true);                                  // Set email format to HTML


        ///send custom code in email

        $code = 242343;

        $mail->Subject = 'TeachMe verification email';

        $mail->Body    = 'Hi <br><br> <b>Thanks for registeration,Your verification code is </b>'.$code;

        $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';


        if(!$mail->send()) {

            echo 'Message could not be sent.';

            echo 'Mailer Error: ' . $mail->ErrorInfo;

        } else {

            echo 'Message has been sent';

        }

    ?>

</body>

</html>


查看完整回答
反對 回復 2023-12-04
  • 1 回答
  • 0 關注
  • 136 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號