2015-09-22 100 views
1

以下代碼顯示「郵件發送成功...」,但發出的郵件未在收件箱的收件箱或垃圾郵件文件夾中收到。在郵件中收不到通過郵件發送的郵件()功能

<?php 
    $to = "[email protected]"; 
    $subject = "This is subject"; 

    $message = "<b>This is HTML message.</b>"; 
    $message .= "<h1>This is headline.</h1>"; 

    $header = "From:[email protected] \r\n"; 
    $retval = mail ($to,$subject,$message,$header); 
    if($retval == true) 
    { 
    echo "Message sent successfully..."; 
    } 
    else 
    { 
    echo "Message could not be sent..."; 
    } 
?> 

我已經改變了[郵件功能]在php.ini像這樣

[mail function] 
SMTP = smtp.gmail.com 
smtp_port = 587 
sendmail_from = [email protected] 
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t" 

而且[sendmail的在sendmail.ini這樣

smtp_server=smtp.gmail.com 
smtp_port=587 
smtp_ssl=tls 
error_logfile=error.log 
pop3_server= 
pop3_username= 
pop3_password= 
force_recipient= 
hostname= 

[email protected] 
auth_password=mymailid_pass 
[email protected] 

所以一切都很好並且$retval返回true,並且echo'Message sent successfully ...',但接收者不會收到他的收件箱或垃圾郵件。 我也啓用imap在gmail settings->forwarding and pop/imap

+0

以下系您的Gmail設置是否正確?從您的其他帳戶(雅虎等)發送測試郵件並檢查您是否收到任何郵件? – jitendrapurohit

+0

你檢查了error.log文件嗎? – Priya

+0

@Priya - 我如何檢查error.log文件在哪裏? –

回答

0
<?php 
    $to = "[email protected]"; 
    $subject = "This is subject"; 

    $message = "<b>This is HTML message.</b>"; 
    $message .= "<h1>This is headline.</h1>"; 

    $header = "From:[email protected] \r\n"; 
    $retval = mail($to,$subject,$message,$header); 
    if(isset($retval))//change 
    { 
     echo "Message sent successfully..."; 
    } 
    else 
    { 
     echo "Message could not be sent..."; 
    } 
?> 

評論中php.ini

sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe" 

Read this answer to Config Your localserver

+0

在我的'php.ini'行'sendmail_path =「C:\ xampp \ mailtodisk \ mailtodisk.exe」'不存在'sendmail_path =「\」C:\ xampp \ sendmail \ sendmail.exe \「-t」'目前和我評論這條線,但仍然不工作 –

+0

不是那條線。還有另一條線。搜索一次 –

+0

不,我搜索過,但只有'sendmail_path =「\」C:\ xampp \ sendmail \ sendmail.exe \「-t」'行存在 –

相關問題