无法使用wp_mail()发送邮件

时间:2015-01-21 06:38:26

标签: php wordpress email

我正在尝试使用wp_mail使用以下代码发送邮件:

$headers[] = 'From: Singhal Competition Classes <example@singhalcompetitionclasses.com>';
        $headers[] = 'Content-Type: text/html; charset=UTF-8';
        $messg = "Hi $user_id .... <br/><br/>Thank You for taking the online exam. Your Score card is as follow : <br/><br/><table><tr><td>
        Total Correct Answer :</td><td> $correct_ansq </td></tr>
        <tr><td>Not Given Answer  </td><td> $no_ans </td></tr>
        <tr><td> Total Wrong Answer </td><td> $wrong <br/></td></tr>
        <tr><td> Percentage </td><td> $result % </td></tr>
        <tr><td>Result </td><td> $result</td></tr></table>
        ";
        $to_mail = $useremail;
        $subject = "Online Exam Score Card";
        wp_mail( $to_mail, $subject, $messg, $headers );

我确实是wp debug但是当完成动作时我没有错误

我既没有接收收件箱中的任何邮件或垃圾邮件

可能出现以下错误

1 个答案:

答案 0 :(得分:0)

以下是一个很好的示例:http://www.tutorialspoint.com/php/php_sending_emails.htm

打开php.ini,填写SMTP和Sendmail部分,并附上您的服务器名称,密码和电子邮件地址。

From website.

[mail function]
; For Win32 only.
SMTP = smtp.secureserver.net

; For win32 only
sendmail_from = webmaster@tutorialspoint.com