# Zend SMTP DKIM not passing

**URL:** <https://discourse.laminas.dev/t/zend-smtp-dkim-not-passing/1194>\
**Category:** Components & MVC\
**Tags:** zend-mail\
**Created:** [September 19, 2019, 12:06pm UTC](https://discourse.laminas.dev/t/zend-smtp-dkim-not-passing/1194 "2019-09-19T12:06:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jilco](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@Jilco](https://discourse.laminas.dev/u/Jilco)\
**Post date:** [September 19, 2019, 12:06pm UTC](https://discourse.laminas.dev/t/zend-smtp-dkim-not-passing/1194/1 "2019-09-19T12:06:14Z")

</div>

Normal emails send from outlook pass DKIM test, but when using script DKIM fails (dkim=fail (signature did not verify)). When using Gmail DKIM passes, outlook doesnt. 3 months ago it also passed outlook, i think that zend messes up the email header, but how to restore that?

```
try {

        $body = 'Bedankt voor uw bericht.<br>';
        $body .= $text;    
        $body .= '<br><br>Met vriendelijke groet, Maintenanceplus';
        
        $html = new MimePart($body);
        $htmlPart->charset = "UTF-8";
        $html->type = "text/html";
        $body = new MimeMessage();
        $body->setParts(array($html,));
                    
        // Create E-mail message
        $message = new Message();
        $message->addTo($recipient)
                ->addFrom('jilcoATmaintenanceplus.nl')
                ->setSubject('Maintenanceplus - contact')
                ->setBody($body)
                ->setEncoding("UTF-8")
                ->setSender("jilcoATmaintenanceplus.nl")
                //->setHeaders($headers)
                ->addCc("jilcoATmaintenanceplus.nl");
        

        
        // Send E-mail message (SMTP)
        $transport = new SmtpTransport();
        $options = new SmtpOptions(array(
                'name' => 'maintenanceplus.nl',
                'host' => '###',
                'port' => 587,
                'connection_class' => 'login',
                'connection_config' => array(
                    'username' => '###',
                    'password' => '###',
                    'ssl' => 'tls',
                ),
            ));
        $transport->setOptions($options);
        $transport->send($message);
        
        $result = true;
    } catch(\Exception $e) {
        $result = false;
    }
    
    // Return status
    return $result;
```

---

<div class="post-metadata">

**Author:** ![Jilco](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@Jilco](https://discourse.laminas.dev/u/Jilco)\
**Post date:** [September 26, 2019, 6:03pm UTC](https://discourse.laminas.dev/t/zend-smtp-dkim-not-passing/1194/2 "2019-09-26T18:03:57Z")

</div>

Found a sollution in adding Message-id header:

```
$messageid = '<'.time() . md5('jilco@maintenanceplus.nl' . $recipient) . '@maintenanceplus.nl>';
        
        $message->getHeaders()->addHeaderLine('Message-ID: ', $messageid);
```
