0

Currently I'm developing an application with Zend Expressive. I'm using zend-mail to send a register email.

However, here's the code:

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

}
}

?>

I got the above error message. ICONV is installed and working.

Here's the code for the call of this function:

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

Regards, Unreality

edigu
  • 9,878
  • 5
  • 57
  • 80
Unreality
  • 3
  • 5
  • where and how are you calling `mimeDecodeValue()`? – Dragos Dec 02 '16 at 09:55
  • zend-mail/src/Header/Date.php is calling the function to assemble email headers. $value = HeaderWrap::mimeDecodeValue($value); – Unreality Dec 02 '16 at 14:51
  • Did you try setting a breakpoint on that line and check in a debugger what is happening in that line specific? – Dragos Dec 02 '16 at 14:59
  • It's trying to jump into the middlewareDispatcher of the zend-stratigility component and then throws a throwable at line 222, stack trace incoming – Unreality Dec 02 '16 at 18:38

1 Answers1

1

enable extension=iconv.so in your php.ini file.

  • ok....I'm feeling stupid right now....you were right. Although iconv seemd to be activated it wasn't actually – Unreality Dec 02 '16 at 18:46
  • For my excuse...docs say it is enabled by default, although it may be disabled by compiling with --without-iconv. That was the issue. – Unreality Dec 02 '16 at 18:52