Error on sending e-mail via SMTP

68
July 12, 2018, at 01:30 AM

This is my code for sending email. But i am getting error and page keeps loading for long time. i am using same server email instead gmail, thats why used localhost. I have used message, to, subject from another page through session. I have also used Pear mail library, My site is currently at eukhost. Someone guide me please.

it's giving me this error:

"Strict Standards: Non-static method PEAR::isError() should not be called statically in /home/caffegin/public_html/fontshop/success.php on line 63 Failed to connect to localhost:465 [SMTP: Invalid response code received from server (code: -1, response: )]"

<?php
session_start();
if (isset($_SESSION['message'])) {
    $message = $_SESSION['message'] ;
}
if (isset($_SESSION['to'])) {
     $to = $_SESSION['to'] ;
}
if (isset($_SESSION['subject'])) {
    $subject = $_SESSION['subject'] ;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <title>Font Shop</title>
</head>
<body>
    <div class="container-fluid">
        <div class="row">
            <div class="header col-lg-2">
                <a href="index.php"><h2>Font Shop</h2></a>
            </div>
        </div>
        <?php
        // Pear Mail Library
        require_once "Mail.php";
        $from = 'no-reply@fontshop.com';
        $headers = array(
            'From' => $from,
            'To' => $to,
            'Subject' => $subject
        );
        $smtp = Mail::factory('smtp', array(
                'host' => 'localhost',
                'port' => '465',
                'auth' => false
                //'username' => 'johndoe@gmail.com',
                //'password' => 'passwordxxx'
            ));
        $mail = $smtp->send($to, $headers, $message);
        if (PEAR::isError($mail)) {
            echo('<p>' . $mail->getMessage() . '</p>');
        } else {
            echo('<div class="success"><h4>Thank you! Your order request is now being processed.</h4></div>');
        }
        ?>
     </div>
<?php
session_unset();
session_destroy();
?>
</body>
</html>
READ ALSO
Use Xdebug with PhpStorm and WSL

Use Xdebug with PhpStorm and WSL

I use WSL (Ubuntu 1614) from Windows 10 as a web server with PHP 7

84
I have a table images and album_images. Is the album_images table unnecessary?

I have a table images and album_images. Is the album_images table unnecessary?

I've created a website where a user can upload a single image or a whole album of images and 3 views - one for displaying all single images, one for displaying all albums (just the title image of each album) and one for displaying all album_images that have album_id...

38
Can you get images from a PHP upload?

Can you get images from a PHP upload?

So I have a page containing PHP that will take multiple images, then save and display them

49
if smiliar foreach then add together Laravel 5.2

if smiliar foreach then add together Laravel 5.2

i want to add the values if they were same and similar

42