梨:邮件不能正常工作

时间:2017-05-22 19:50:15

标签: php html web pear

这似乎行不通。我的webhost声称安装了PEAR。有人发现任何错误吗?我确实每个var / field都是正确的。但是,当它运行时,它会停止加载php html页面的其余部分。

<?php
// Report all PHP errors
error_reporting(-1);

if (isset($_POST['email'])) {
    require_once "Mail.php";

    $from = "No Reply <redacted@redacted.redacted>";
    $to = "redacted";
    $subject = "Hi!";
    $body = "Hi,\n\nHow are you?";

    $host = "redacted.redacted.redacted";
    $username = "redacted@redacted.redacted";
    $password = "---";

    $headers = array ('From' => $from,
        'To' => $to,
        'Subject' => $subject);

    $smtp = Mail::factory('smtp',
        array ('host' => $host,
            'auth' => true,
            'username' => $username,
            'password' => $password));

    $mail = $smtp -> send($to, $headers, $body);

    if (PEAR::isError($mail)) {
        echo("<p>" . $mail -> getMessage() . "</p>");
    } else {
        echo("<p>Message successfully sent!</p>");
    }

}
?>

0 个答案:

没有答案