0
votes

I have this error while trying to improve PHPMailer for sending automatic emails in my website:

Fatal error: Call to a member function authorise() on a non-object in /home/u289995868/public_html/es/php/class.user.php on line 116


The 'corrupted' code in the file is this:

function send_mail($email,$message,$subject)
    {      
        require_once 'mailer/class.phpmailer.php';
        require_once 'mailer/class.pop3.php';
        $pop->authorise('mx1.hostinger.es', 110, 30, '[email protected]', 'xxxxxxxx', 1);
        $mail = new PHPMailer(); 
        $mail->SMTPDebug = 2; 
        $mail->isSMTP();
        $mail->isHTML(false); 
        $mail->Host = 'mx1.hostinger.es';
        $mail->From = '[email protected]';
        $mail->FromName = 'Admin de barreeeiroo.ga';
        $mail->Subject = $subject;
        $mail->Body = $message;
        $mail->addAddress($email);
        if (!$mail->send()) {
            echo $mail->ErrorInfo;
        }
    } 


Corrupted line is $pop->authorise(...);.

You can take a look to the require_once files here: GitHub.


Thanks for the answer.

2
there are no object $pop inside your function visibility scopealexander.polomodov
you should probably add the code of the required file, so that the answer will always fit the reason. If you don't, no one will understand this question post update.Unex
Like Unex says - if you had posted your code in your Github issue, you might have got an answer.Synchro
I didn't posted an issue on Github; I taged that Github repository because I imported that code, that's itDiego Barreiro
So I imagined this?Synchro

2 Answers

0
votes

$pop cannot be used outside of popBeforeSmtp() method. Try:

require_once 'mailer/class.phpmailer.php';
require_once 'mailer/class.pop3.php';
$pop = new POP3;
$pop->authorise('mx1.hostinger.es', 110, 30, '[email protected]', 'xxxxxxxx', 1);
$mail = new PHPMailer(); 
$mail->SMTPDebug = 2; 
$mail->isSMTP();
$mail->isHTML(false); 
$mail->Host = 'mx1.hostinger.es';
$mail->From = '[email protected]';
$mail->FromName = 'Admin de barreeeiroo.ga';
$mail->Subject = $subject;
$mail->Body = $message;
$mail->addAddress($email);
if (!$mail->send()) {
    echo $mail->ErrorInfo;
}
0
votes

The variable $pop is not initialized within your function so what you are actually doing is null->authorise(...);, which makes no sense.