SDKiller / zyx-phpmailer

PHPMailer integration for Yii2 framework
BSD 3-Clause "New" or "Revised" License
2 stars 5 forks source link

Call to undefined method zyx\phpmailer\Adapter::normalizeBreaks() #6

Closed gianx89 closed 8 years ago

gianx89 commented 9 years ago

When I send and email with this code:

Yii::$app->mailer->compose()
     ->setFrom(['net@test.com' => 'My Example Site'])
     ->setTo(Yii::$app->getRequest()->getQueryParam('mailbox'))
     ->setSubject('Impostazioni mailbox')
     ->setTextBody($file)
     ->send();

I get this error from the debugger:

Call to undefined method zyx\phpmailer\Adapter::normalizeBreaks()

This happens because in the Adapter.php file the normalizeBreaks() method is called:

    /**
     * Sets message plain text content.
     * @param string $text message plain text conten
     * @return void
     */
    public function msgText($text)
    {
        $this->isHTML(false);
        $text = self::html2text($text, true);
        $text = self::normalizeBreaks($text);
        $this->Body = $text;
    }

But not implemented. If I comment out this call, it works like a charm. But I don't want to modify the source code downloaded via composer so, can you fix the error and make a commit?

SDKiller commented 9 years ago

Hi. Its strange.

as Adapter is extended from phpMailer - so \PHPMailer::normalizeBreaks method is called in this case and its working for me.

Could you please try to replace self with static like this

$text = static::normalizeBreaks($text);

Check if it will work for you and let me know - I'll try to investigate the issue deeper.