没有收到邮件发送的邮件()函数在PHP中

时间:2015-09-22 10:14:22

标签: php email xampp

以下代码显示“邮件已成功发送...”但发送的邮件未在收件人的收件箱或垃圾邮件文件夹中收到。

<?php
    $to = "rcvr@example.com";
    $subject = "This is subject";

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

    $header = "From:mymailid@gmail.com \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],就像这样

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

sendmail.ini中的[sendmail]就像这样

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

auth_username=mymailid@gmail.com
auth_password=mymailid_pass
force_sender=mymailid@gmail.com

所以一切都很好,$retval返回true并回显'消息已成功发送...'但接收者不会在收件箱或垃圾邮件中获取它。 我还在gmail imap中启用了settings->forwarding and pop/imap

1 个答案:

答案 0 :(得分:0)

<form name="repaymentcalc" action="">
  <div align="center">
    </br>

    <p>
      Home Value £
      <input type="number" id="homevalue" value="250000" style="width: 75px">
    </p>

    <p>
      Loan Amount £
      <input type="number" id="loanamount" value="200000" style="width: 75px">
    </p>

    <p>
      Interest Rate
      <input type="number" id="interestrate" value="3.00" style="width: 50px">%
    </p>

    Term
    <input type="range" id="numberpayments" value="25" min="1" max="40" style="width: 100px">
    <div id="years" style="display:inline-block;">25 years

    </div>

    <div id="repayments">Monthly Repayment: £948.42</div>
    <p>
      <div id="ltv">Loan to Value: 80.0%</div>

  </div>
</form>

评论<?php $to = "rcvr@example.com"; $subject = "This is subject"; $message = "<b>This is HTML message.</b>"; $message .= "<h1>This is headline.</h1>"; $header = "From:mymailid@gmail.com \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

Read this answer to Config Your localserver