调用未定义的函数Zend \ Mail \ Header \ iconv_mime_decode()

时间:2016-12-02 09:49:08

标签: php email zend-framework zend-expressive

目前我正在使用Zend Expressive开发应用程序。 我使用zend-mail发送注册邮箱。

但是,这里是代码:

<?php

namespace App\Mail\Service;

use Zend\Mail\Transport\Smtp;
use Zend\Mail\Transport\SmtpOptions;
use Zend\Mail\Message;

class MailService
{
    private $transport;
    private $options;

public function __construct() {
    $this->transport = new Smtp();
    $this->options =  new SmtpOptions([
        'name' => 'XXXXXX',
        'host' => 'XXXXXX',
        'port' => 587,
        'connection_class'  => 'plain',
        'connection_config' => [
            'username'  => 'XXXXXX',
            'password'  => 'XXXXXX',
            'ssl'       => 'tls'
        ],
    ]);
    $this->transport->setOptions($this->options);
}

public function sendRegisterMail($email)
{
    $message = new Message();
    $message->addFrom('XXXXXX', 'XXXXXX');
    $message->addTo($email);
    $message->setEncoding("UTF-8");
    $message->getHeaders()->addHeaderLine('Content-Type', 'text/plain; charset=UTF-8');
    $message->setSubject('Subject');
    $message->setBody('This is the Message Body');

    $this->transport->send($message);

}
}

?>

我收到了上述错误消息。 ICONV已安装并正常运行。

这是调用此函数的代码:

public static function mimeDecodeValue($value)
{
    $decodedValue = iconv_mime_decode($value, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8');
    return $decodedValue;
}

此致 非现实

1 个答案:

答案 0 :(得分:0)

在php.ini文件中启用extension = iconv.so。