第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

PHP郵件功能無法完成電子郵件的發(fā)送

PHP郵件功能無法完成電子郵件的發(fā)送

www說 2019-05-20 15:13:54
<?php     $name = $_POST['name'];     $email = $_POST['email'];     $message = $_POST['message'];     $from = 'From: yoursite.com';      $to = 'contact@yoursite.com';      $subject = 'Customer Inquiry';     $body = "From: $name\n E-Mail: $email\n Message:\n $message";     if ($_POST['submit']) {         if (mail ($to, $subject, $body, $from)) {              echo '<p>Your message has been sent!</p>';         } else {              echo '<p>Something went wrong, go back and try again!</p>';          }     }?>我試過創(chuàng)建一個(gè)簡(jiǎn)單的郵件表單。表單本身在我的index.html頁面上,但提交單獨(dú)的“謝謝你的提交”頁面thankyou.php,其中嵌入了上面的PHP代碼。代碼提交完美,但從不發(fā)送電子郵件。請(qǐng)幫忙。
查看完整描述

7 回答

?
收到一只叮咚

TA貢獻(xiàn)1821條經(jīng)驗(yàn) 獲得超5個(gè)贊

在郵件功能中添加郵件標(biāo)題

$header = "From: noreply@example.com\r\n"; $header.= "MIME-Version: 1.0\r\n"; $header.= "Content-Type: text/html; charset=ISO-8859-1\r\n"; 
$header.= "X-Priority: 1\r\n"; $status = mail($to, $subject, $message, $header);if($status){ 
    echo '<p>Your mail has been sent!</p>';} else { 
    echo '<p>Something went wrong, Please try again!</p>'; }


查看完整回答
反對(duì) 回復(fù) 2019-05-20
?
德瑪西亞99

TA貢獻(xiàn)1770條經(jīng)驗(yàn) 獲得超3個(gè)贊

  1. 始終嘗試在郵件功能中發(fā)送標(biāo)題。

  2. 如果您通過localhost發(fā)送郵件,請(qǐng)執(zhí)行smtp設(shè)置以發(fā)送郵件。

  3. 如果您通過服務(wù)器發(fā)送郵件,請(qǐng)檢查服務(wù)器上是否啟用了電子郵件發(fā)送功能。


查看完整回答
反對(duì) 回復(fù) 2019-05-20
?
有只小跳蛙

TA貢獻(xiàn)1824條經(jīng)驗(yàn) 獲得超8個(gè)贊

通過執(zhí)行以下操作,它在000webhost上為我工作:


$headers  = "MIME-Version: 1.0" . "\r\n";$headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";$headers .= "From: ". $from. "\r\n";$headers .= "Reply-To: ". $from. "\r\n";$headers .= "X-Mailer: PHP/" . phpversion();$headers .= "X-Priority: 1" . "\r\n"; 

發(fā)送電子郵件時(shí)直接輸入電子郵件地址


mail('email@gmail.com', $subject, $message, $headers)

使用''與否""


此代碼有效,但收到的電子郵件滯后半小時(shí)



查看完整回答
反對(duì) 回復(fù) 2019-05-20
?
白衣染霜花

TA貢獻(xiàn)1796條經(jīng)驗(yàn) 獲得超10個(gè)贊

大部分mail()功能在共享主機(jī)中被禁用。更好的選擇是使用SMTP。最好的選擇是Gmail或SendGrid。


SMTPconfig.php


<?php 

    $SmtpServer="smtp.*.*";

    $SmtpPort="2525"; //default

    $SmtpUser="***";

    $SmtpPass="***";

?>

SMTPmail.php


<?php

class SMTPClient

{


    function SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to, $subject, $body)

    {


        $this->SmtpServer = $SmtpServer;

        $this->SmtpUser = base64_encode ($SmtpUser);

        $this->SmtpPass = base64_encode ($SmtpPass);

        $this->from = $from;

        $this->to = $to;

        $this->subject = $subject;

        $this->body = $body;


        if ($SmtpPort == "") 

        {

            $this->PortSMTP = 25;

        }

        else

        {

            $this->PortSMTP = $SmtpPort;

        }

    }


    function SendMail ()

    {

        $newLine = "\r\n";

        $headers = "MIME-Version: 1.0" . $newLine;  

        $headers .= "Content-type: text/html; charset=iso-8859-1" . $newLine;  


        if ($SMTPIN = fsockopen ($this->SmtpServer, $this->PortSMTP)) 

        {

            fputs ($SMTPIN, "EHLO ".$HTTP_HOST."\r\n"); 

            $talk["hello"] = fgets ( $SMTPIN, 1024 ); 

            fputs($SMTPIN, "auth login\r\n");

            $talk["res"]=fgets($SMTPIN,1024);

            fputs($SMTPIN, $this->SmtpUser."\r\n");

            $talk["user"]=fgets($SMTPIN,1024);

            fputs($SMTPIN, $this->SmtpPass."\r\n");

            $talk["pass"]=fgets($SMTPIN,256);

            fputs ($SMTPIN, "MAIL FROM: <".$this->from.">\r\n"); 

            $talk["From"] = fgets ( $SMTPIN, 1024 ); 

            fputs ($SMTPIN, "RCPT TO: <".$this->to.">\r\n"); 

            $talk["To"] = fgets ($SMTPIN, 1024); 

            fputs($SMTPIN, "DATA\r\n");

            $talk["data"]=fgets( $SMTPIN,1024 );

            fputs($SMTPIN, "To: <".$this->to.">\r\nFrom: <".$this->from.">\r\n".$headers."\n\nSubject:".$this->subject."\r\n\r\n\r\n".$this->body."\r\n.\r\n");

            $talk["send"]=fgets($SMTPIN,256);

            //CLOSE CONNECTION AND EXIT ... 

            fputs ($SMTPIN, "QUIT\r\n"); 

            fclose($SMTPIN); 

            // 

        } 

        return $talk;

    } 

}

?>

contact_email.php


<?php 

include('SMTPconfig.php');

include('SMTPmail.php');

if($_SERVER["REQUEST_METHOD"] == "POST")

{

    $to = "";

    $from = $_POST['email'];

    $subject = "Enquiry";

    $body = $_POST['name'].'</br>'.$_POST['companyName'].'</br>'.$_POST['tel'].'</br>'.'<hr />'.$_POST['message'];

    $SMTPMail = new SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to, $subject, $body);

    $SMTPChat = $SMTPMail->SendMail();

}

?>


查看完整回答
反對(duì) 回復(fù) 2019-05-20
  • 7 回答
  • 0 關(guān)注
  • 4582 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)