lundi 22 mai 2017

PHP PEAR not working

This seems to not work. My webhost claims to have PEAR installed. Does anybody spot any mistakes? I do have every var/field correct. But yet, when this runs, it stops the loading of the rest of the php html page.

        <?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>");
            }

        }
        ?>




Aucun commentaire:

Enregistrer un commentaire