Giter Club home page Giter Club logo

laminas-mail's Introduction

laminas-mail

Build Status

🇷🇺 Русским гражданам

Мы, участники Laminas, родились и живем в разных странах. У многих из нас есть друзья, родственники и коллеги как в России, так и в Украине. Некоторые из нас родились в России. Некоторые из нас живут в России. У некоторых бабушки и дедушки сражались с фашистами во Второй мировой войне. Здесь никто не поддерживает фашизм.

У одного из нас есть украинская родственница, которая спаслась из дома вместе с сыном. Поезд задержался из-за бомбежки на дороге впереди. У нас есть друзья, которые прячутся в бомбоубежищах. Мы с тревогой ждем весточки от них после воздушных налетов, которые беспорядочно наносят удары и попадают по больницам, школам, детским садам и домам. Мы не берем это из каких-либо СМИ. Мы наблюдаем это напрямую.

Вы доверяете нам достаточно, чтоб использовать наши программы, и мы просим вас довериться нам вновь. Мы нуждаемся в помощи. Выходите и протестуйте против этой бесполезной войны. Остановите кровопролитие. Скажите "Нет войне!"

🇺🇸 To Citizens of Russia

We at Laminas come from all over the world. Many of us have friends, family and colleagues in both Russia and Ukraine. Some of us were born in Russia. Some of us currently live in Russia. Some have grandparents who fought Nazis in World War II. Nobody here supports fascism.

One team member has a Ukrainian relative who fled her home with her son. The train was delayed due to bombing on the road ahead. We have friends who are hiding in bomb shelters. We anxiously follow up on them after the air raids, which indiscriminately fire at hospitals, schools, kindergartens and houses. We're not taking this from any media. These are our actual experiences.

You trust us enough to use our software. We ask that you trust us to say the truth on this. We need your help. Go out and protest this unnecessary war. Stop the bloodshed. Say "stop the war!"

Laminas\Mail provides generalized functionality to compose and send both text and MIME-compliant multipart email messages. Mail can be sent with Laminas\Mail via the Mail\Transport\Sendmail, Mail\Transport\Smtp or the Mail\Transport\File transport. Of course, you can also implement your own transport by implementing the Mail\Transport\TransportInterface.

laminas-mail's People

Contributors

akrabat avatar ameir avatar bakura10 avatar dasprid avatar davidwindell avatar evandotpro avatar ezimuel avatar fredden avatar freeaqingme avatar froschdesign avatar ghostwriter avatar glensc avatar gsteel avatar maks3w avatar marc-mabe avatar michalbundyra avatar mikaelkael avatar mleko avatar mwillbanks avatar ocramius avatar padraic avatar prolic avatar ralphschindler avatar renovate[bot] avatar samsonasik avatar sgehrig avatar slamdunk avatar thinkscape avatar weierophinney avatar xerkus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laminas-mail's Issues

email with X-Face header can not be parsed

X-Face: -wlbD9'=rreR]%7k=U/$9SH49NUKg%87&q@LL/f-N8J5fAS$(eMSkqGYAX{V?:}ZP7&|@~
        lR"jz-sU-yjj4Om?"#^&RQ/D1X}NaJG''pmX\qOjp;Mejrcq?~.iVv*)nD(-c4kSQvL.N=
        q_9[7vt;C$!vga6l_O1d52OWygzjb-XrS]-

yields:

Line "X-Face: -wlbD9'=rreR]%7k=U/$9SH49NUKg%87&q@LL/f-N8J5fAS$(eMSkqGYAX{V?:}ZP7&|@~ lR"jz-sU-yjj4Om?"#^&RQ/D1X}NaJG''pmX\qOjp;Mejrcq?~.iVv*)nD(-c4kSQvL.N= q_9[7vt;C$!vga6l_O1d52OWygzjb-XrS]-"does not match header format!

This can be tested with online tool

example

image


Originally posted by @glensc at zendframework/zend-mail#198

fix read of 8192 bytes failed with errno=21 Is a directory

With 7.4.0RC3

There was 1 error:
1) ZendTest\Mail\Storage\MboxFolderTest::testChangeFolderUnselectable
fgets(): read of 8192 bytes failed with errno=21 Is a directory
/builddir/build/BUILDROOT/php-zendframework-zend-mail-2.10.0-5.fc32.noarch/usr/share/php/Zend/Mail/Storage/Mbox.php:232
/builddir/build/BUILDROOT/php-zendframework-zend-mail-2.10.0-5.fc32.noarch/usr/share/php/Zend/Mail/Storage/Mbox.php:268
/builddir/build/BUILDROOT/php-zendframework-zend-mail-2.10.0-5.fc32.noarch/usr/share/php/Zend/Mail/Storage/Folder/Mbox.php:164
/builddir/build/BUILD/zend-mail-d7beb63d5f7144a21ac100072c453e63860cdab8/test/Storage/MboxFolderTest.php:143

This is a trivial fix which "also" mute E_NOTICE raised by fgets


Originally posted by @remicollet at zendframework/zend-mail#244

Fix AddressList toString method to quote semicolon

Certain input of AddressList headers, cannot be converted to string and back to header object because of incorrect quoting:

From: "Foo;" <[email protected]>

gets incorrectly converted as

From: Foo; <[email protected]>

but ; is address separator, so it needs to be quoted:

From: "Foo;" <[email protected]>

The problem I discovered internally when using Storage\Message with Headers input, therefore testing that method is included in the unit test:

$message = new Message(['headers' => new Headers(), 'content' => (string)$body]);

// Mime\Decode::splitMessage calls toString on headers object which creates invalid result:
if ($message instanceof Headers) {
    $message = $message->toString();
}

Originally posted by @glensc at zendframework/zend-mail#230

getFolders - Parsing literals ends into a endless loop

When a response contains a literal php ends in an endless loop.

See RFC about literals: https://tools.ietf.org/html/rfc3501#section-4.3

Below a snippet of the response of imap command A1 LIST "" *

* LIST (\HasNoChildren) "/" {16}
Intern/test "23"

This snippet is the cause of the endless loop. Problem seems to be the appending of a space in Zend\Mail\Protocol in method decodeLine.
$line = trim($line) . ' ';
should be

$line = trim($line) ;


Originally posted by @fasterforward at zendframework/zend-mail#191

Content-Type paramater does not trim paramater name

Hello,

I am getting filenames for attachments using the getParameter() on the content-type header. I noticed some email parts that were supposed to be attachments did not have a filename. Inspecting the source header, I could see that there was in fact a filename set. Further inspection showed that the parameter name was being added with a leading space. I would expect that leading spaces would be trimmed.

Thanks,

Cody

Code to reproduce the issue

use Zend\Mail\Header\ContentType;
$ct = ContentType::fromString('Content-Type: text/plain; charset=utf-8; name="logfile.log";');
printf('r1 "%s"'.PHP_EOL, $ct->getParameter('name'));
printf('r2 "%s"'.PHP_EOL, $ct->getParameter(' name'));
var_dump($ct);

Actual results

r1 ""
r2 "logfile.log"
object(Zend\Mail\Header\ContentType)#3 (3) {
  ["type":protected]=>
  string(10) "text/plain"
  ["encoding":protected]=>
  string(5) "ASCII"
  ["parameters":protected]=>
  array(2) {
    ["charset"]=>
    string(5) "utf-8"
    [" name"]=>
    string(11) "logfile.log"
  }
}

My Fix

I would not presume to understand the best place to resolve this, but this hack solved my problem for the time being

$ diff ContentType.php ContentType.php.new
55c55
<                 $header->addParameter($values[$i], $value);
---
>                 $header->addParameter(trim($values[$i]), $value);

Originally posted by @cody121 at zendframework/zend-mail#220

Zend\Mail\Storage\Maildir Instance Problems and EOL Parameter

Hi all,

i have a directory with a huge amount of Mails, so i decided to use the Zend\Mail\Storage\Maildir Class for getting all Mails within this directory. See my code:

<?php

use Zend\Mail\Storage\Maildir;

require __DIR__ . '/vendor/autoload.php';

$mails = new MailDir(
    array(
        'dirname' => __DIR__ . '/maildir/',
    )
);

$count  = $mails->countMessages();
$emails = array();

$message = $mails->getMessage(1);

var_dump($message->getHeaders()->get('To')->getFieldValue());

I guess there is an bug and an unhandled feature.

Bug: With the code above i got an exception

Fatal error: Uncaught exception 'Zend\Mail\Storage\Part\Exception\InvalidArgumentException' with message 'no file given in params' in /Users/nico/Workspaces/MailTest/vendor/zendframework/zend-mail/src/Storage/Part/File.php on line 37

The problem is that in Maildir.php::getMessage($id)

    public function getMessage($id)
    {
        // TODO that's ugly, would be better to let the message class decide
        if ($this->messageClass === Message\File::class
            || is_subclass_of($this->messageClass, Message\File::class)
        ) {
            return new $this->messageClass([
                'file'  => $this->getFileData($id, 'filename'),
                'flags' => $this->getFileData($id, 'flags'),
            ]);
        }

        return new $this->messageClass([
            'handler' => $this,
            'id'      => $id,
            'headers' => $this->getRawHeader($id),
            'flags'   => $this->getFileData($id, 'flags'),
        ]);
    }

At least in PHP 5.5.30, other i couldn't test at the moment, the if isn't true, and so the Message/File class is called with wrong parameters.

is_subclass_of($this->messageClass, Message\File::class) // = false
$this->messageClass // = \Zend\Mail\Storage\Message\File
Message\File::class // = Message\File

So i used my own Maildir class as a child class:

class MyMailDir extends \Zend\Mail\Storage\Maildir
{
    public function __construct($params)
    {
        parent::__construct($params);
    }

    public function getMessage($id)
    {
            // TODO that's ugly, would be better to let the message class decide
        if (strtolower($this->messageClass) == '\zend\mail\storage\message\file'
            || is_subclass_of($this->messageClass, '\Zend\Mail\Storage\Message\File')) {
            return new $this->messageClass(
                [
                    'file'  => $this->getFileData($id, 'filename'),
                    'flags' => $this->getFileData($id, 'flags'),
                    'EOL'   => "\n",
                ]
            );
        }

        return new $this->messageClass(['handler' => $this, 'id' => $id, 'headers' => $this->getRawHeader($id),
            'flags'   => $this->getFileData($id, 'flags')]);
    }
}

For now i could instance and run getMessage correctly.

Unhandled Feature: Furthermore in Part\File.php there is a possibility to call Headers::from String with EOL Parameter. To use this feature also with Maildir class it should be possible to hand over the parameter from params. Example above in MyMailDir::getMessage($id). Okay it should come from initial parameters for example:

$mails = new MailDir(
    array(
        'dirname' => __DIR__ . '/maildir/',
        'EOL' => "\n",
    )
);

Originally posted by @nicohofmann at zendframework/zend-mail#109

message cloning and headers

  • I was not able to find an open or closed issue matching what I'm seeing.
  • This is not a question. (Questions should be asked on chat (Signup here) or our forums.)

I have a service that has an injected default message. It has some default fields, such as encoding, from_name, from which are equal for any mail sent.

Internally it will create a clone from the default message and then it will add the actual rendered content, to subject. etc. It also adds Content-Type and an X-Header.

However at some point I noticed messages were having duplicate Content-Type and X-Header headers and some servers will deny those messages. Every time a message is sent and additional header is added. (this is a long running process)

Code to reproduce the issue

        $defaultMessage = new \Zend\Mail\Message();
        $defaultMessage->setFrom('[email protected]');

        $message1 = clone $defaultMessage;
        $message1->getHeaders()->addHeaderLine('X-Something', 1);

        $message2 = clone $defaultMessage;
        $message2->getHeaders()->addHeaderLine('X-Something', 2);

        print $message1->toString();
        print $message2->toString();

Expected results

Headers should be unique due to the clone of the default message

Date: Thu, 14 Jun 2018 08:53:20 +0000
From: [email protected]
X-Something: 1

Date: Thu, 14 Jun 2018 08:53:20 +0000
From: [email protected]
X-Something: 2

Actual results

Date: Thu, 14 Jun 2018 08:53:20 +0000
From: [email protected]
X-Something: 1
X-Something: 2

Date: Thu, 14 Jun 2018 08:53:20 +0000
From: [email protected]
X-Something: 1
X-Something: 2

I'm aware normally one should create a new Message for each Message you attempt to sent. I have changed my code to do this, but I still think this should simply work. I'm wondering why clone doesn't really clone...


Originally posted by @basz at zendframework/zend-mail#214

Zend\Mail\Storage\Mbox can't fetch messages due to header issues

PHP 7.2.2, Zend Mail at it's latest version as of today.

I'm opening an old mailbox file generated by Mozilla Thunderbird (please note that I get the same issue with other Thunderbird mailbox files). It has 2,521 messages and every single one of them causes this Zend\Mail\Exception\RuntimeException.

This issue happens:

  1. When trying to iterate through the mailbox file with a foreach (as shown in the docs);
  2. When trying to fetch a specific message after iterating via a count() + regular for loop .

And it's located at zendframework/zend-mail/src/Headers.php on line 109.

The exact headers causing the issue are X-Mozilla-Status and X-Account-Key. See the sample below (I've removed [potentially] sensitive data such as e-mail addresses, etc... for obvious reasons).

Line "X-Mozilla-Status: 0019
X-Mozilla-Status2: 00000000
X-Mozilla-Keys:                                                                                 
Received: (qmail 20021 invoked from network); 24 Apr 2008 14:23:38 -0300
Received: from [redacted].google.com (216.239.58.185) by [redacted]
        with SMTP; 24 Apr 2008 14:23:38 -0300
Received-SPF: softfail ([redacted]: transitioning SPF record at
        [redacted] does not designate [redacted] as permitted sender)
Received: by [redacted].google.com with SMTP id [redacted] for
        <[redacted]>; Thu, 24 Apr 2008 11:36:07 -0700 (PDT)
Received: by 10.150.49.1 with SMTP id [redacted]; Thu,
        24 Apr 2008 11:35:17 -0700 (PDT)
Received: by [redacted] with HTTP; Thu, 24 Apr 2008 11:35:17 -0700 (PDT)
Message-ID: <[redacted]@mail.gmail.com>
Date: Thu, 24 Apr 2008 15:35:17 -0300
From: "[redacted]" <[redacted]>
To: [redacted]
Subject: =?ISO-8859-1?[redacted]?=
In-Reply-To: <[redacted]>
MIME-Version: 1.0
Content-Type: multipart/related;  boundary="----=_Part_22_2026612.1209062117791"
References: <[redacted]>
X-Evolution-Source: [redacted]
X-Evolution: [redacted]
" does not match header format!


Originally posted by @galvao at zendframework/zend-mail#193

Throwing email invalid exception on the email from field of emails being read from an IMAP server

  • I was not able to find an open or closed issue matching what I'm seeing.
  • This is not a question. (Questions should be asked on chat (Signup here) or our forums.)

I am attempting to read bounced emails and mark the address as bouncy.

Code to reproduce the issue

        //connect to the mail server
        $mail = new Imap([
            'host'     => 'REDACTED',
            'port'     => '993',
            'user'     => 'REDACTED',
            'password' => 'REDACTED',
            'ssl'      => 'SSL'
        ]);

        //open the bounced folder
        $folder = $mail->getFolders()->Bounced;
        $mail->selectFolder($folder);
        
        //will throw an Exception: The input is not a valid email address. Use the basic format local-part@hostname /vendor/zendframework/zend-mail/src/Address.php 77 if it encounters an email from "[email protected]" - it will wrongly interpret the email address as simply "MAILER-DAEMON"
        foreach ($mail as $messageNum => $message) {
        }

Expected results

When trying to parse a fairly standard bounced email that comes from [email protected] it will throw an exception stating that MAILER-DAEMON is not a valid email address.

I suppose it should parse the email from address properly... or perhaps it should have an option to ignore these types of exceptions - since we are not constructing an email, and are simply parsing an email that exists on an actual email server it doesn't make much sense to throw an interrupting exception stating that the email is invalid, when it is in fact a real email that exists on a real mailserver. Since the exception is encountered during a foreach iteration it's not even an option to simply catch and ignore the exception.

Actual results

Exception: The input is not a valid email address. Use the basic format local-part@hostname /vendor/zendframework/zend-mail/src/Address.php 77


Originally posted by @ibindoff at zendframework/zend-mail#248

Not overriding from mail header

When using smtp transport api for sending mail, 'from' header doesn't change by using
->setFrom() or ->setSender() and 'from' header always remains the same email address used for smtp user for authentication. In following example, from email address remains same as '[email protected]' instead of '[email protected]'.

Note: Sender name gets changed with 'Some Sender' (but not the email)

$transport = new SmtpTransport();
$options = new SmtpOptions();
$options->setHost('smtp.gmail.com')
                ->setConnectionClass('login')
                ->setName('smtp.gmail.com')
                ->setConnectionConfig(array(
                    'username' =>'[email protected]',
                    'password' => 'mypassword',
                    'ssl' => 'tls'
        ));
$transport->setOptions($options);
 
$mail = new Zend_Mail();
$mail->setBodyText('This is the text of the mail.');
$mail->setFrom('[email protected]', 'Some Sender');
$mail->addTo('[email protected]', 'Some Recipient');
$mail->setSubject('TestSubject');
$mail->send($transport);

Originally posted by @vinodkumar30 at zendframework/zend-mail#122

testcase for broken Header\AbstractAddressList::fromString

Problem:

  1. GenericHeader loads the header in file, decodes it to utf-8
  2. the Headers::get attempts to Lazy-Load "To" header class

Lazyload does stringify and load in from string

$encoding = $current->getEncoding();
$headers  = $class::fromString($current->toString());

However, toString does not encode comma
AND To header class does split on comma!

see \Zend\Mail\Header\AbstractAddressList::fromString

this PR shows only the problem.


Originally posted by @glensc at zendframework/zend-mail#146

ListParse not work with cyrillic

dump(
    ListParser::parse(' value="price 1.xlsx"; attribute=""', [';', '=']),
    ListParser::parse(' value="Прайс 2.xlsx"; attribute=""', [';', '='])
);

array:4 [
  0 => " value"
  1 => ""price 1.xlsx""
  2 => " attribute"
  3 => """"
]
array:3 [
  0 => " value"
  1 => ""Прайс 2.xlsx""
  2 => " attribu"
]

Originally posted by @dimaxz at zendframework/zend-mail#243

IMAP OAuth Authentication (XOAUTH2)

Hi,

Is it possible to add XOAUTH2-authentication to the Zend Mail IMAP? See google/gmail-oauth2-tools#18

The solution suggested by Google is not perfect, as it first tries to connect via regular authentication and only after that performs OAuth-authenticaiton.

Here is the implementation of the IMAP OAuth for Zend Mail IMAP: https://github.com/ialert/imap-xoauth2. You just need to add it to your repo.


Originally posted by @freescout-helpdesk at zendframework/zend-mail#252

Zend mail DKIM failes

DKIM passed with zend previous versions (als on Magento), now dkim failes when using zend. When using Outlook with same SMTP settings, dkim passes.

Code to reproduce the issue

$message = new Message();
        $message->addTo($recipient)
                ->addFrom(****)
                ->setSubject('Maintenanceplus - contact')
                ->setBody($body);
        
        // Send E-mail message (SMTP)
        $transport = new SmtpTransport();
        $options   = new SmtpOptions(array(
                'name'              => 'maintenanceplus.nl',
                'host'              => 'mail.maintenanceplus.nl',
                'port'              => 587,
                'connection_class'  => 'login',
                'connection_config' => array(
                    'username' => *,
                    'password' => *
                    'ssl' => 'tls'
                ),
            ));
        $transport->setOptions($options);
        $transport->send($message);

Expected results

Mail is send to recipent with passed dkim

Actual results

dkim failed with zend, but when sending via outlook (same smtp settings) the dkim passes. Also in my Magento webstore the same happens!


Originally posted by @Jilco at zendframework/zend-mail#242

Replace error handler with error_get_last() function

Hi, guys.

I just found that mail() function does not generate the proper error that can be handled by handleMailErrors() method ("Temporary error handler for PHP native mail()" as pointed in the phpdoc). I have an msmtp as email agent with following settings in php.ini:

sendmail_path = "/usr/bin/msmtp -C /etc/.msmtp.fpm --logfile /var/log/msmtp.log --read-envelope-from -a gmail -t"

I have an error in \Zend\Mail\Transport\Sendmail::mailHandler if

$parameters = " -f'[email protected]'";

in

$result = mail($to, $subject, $message, $headers, $parameters);

As I see, there is a conflict between --read-envelope-from option of msmtp and -f'[email protected]' parameter of mail function. So, mail function returns false in this case.

But this code does not handle the error as expected. The breakpoint in handleMailErrors method does not activated when error occurs (I have PHP 7.2.19 & PHPStorm 2019.1.3).

I found that error_get_last() function may help in this case.

In addition I think we should not throw an exception if $result is true.

So, I suppose, the final code for mailHandler should be the following:

public function mailHandler($to, $subject, $message, $headers, $parameters)
{
    if ($parameters === null) {
        $result = mail($to, $subject, $message, $headers);
    } else {
        $result = mail($to, $subject, $message, $headers, $parameters);
    }

    if (!$result) {
        $errstr = error_get_last()['message'];
        if (empty($errstr)) {
            $errstr = 'Unknown error';
        }
        throw new Exception\RuntimeException('Unable to send mail: ' . $errstr);
    }
}

Sorry, my qualification is not enough to complete all items you want to see here (regression test, CHANGELOG.md, etc.). But I hope my point of view may be useful.

Have a good day!


Originally posted by @flancer64 at zendframework/zend-mail#229

Update documentation about dependency ServiceManager

  • I was not able to find an open or closed issue matching what I'm seeing.
  • This is not a question. (Questions should be asked on chat (Signup here) or our forums.)

Using the most complete version of the component with SmtpOptions and SmtpTransport a dependency error is reported and in relation to this has already been discussed previously.

problem and solution #62

But the documentation is not good for this use.

I suggest that in these two links be informed about the dependency:

(1) https://docs.zendframework.com/zend-mail/transport/smtp-authentication/#smtp-authentication
(2) https://docs.zendframework.com/zend-mail/transport/smtp-options/


Originally posted by @eduardobona at zendframework/zend-mail#219

SMTP protocol: error in function rcpt ?

Hi,
First: sorry if my english is not perfect :-)

In my company, a project (currently in development) is using Zend\Mail with SMTP protocol to send email

When a mail is sent with multiple recipients (to, cc and bcc), the SMTP server checks email addresses, return a error code 550 5.1.1 if one doesn't exists and a exception is thrown by Zend\Mail\Protocol\Smtp => and the email is not send at all

BUT, in RFC (RFC 2821), it is said:

The second step in the procedure is the RCPT command.
RCPT TO: [ SP ]

The first or only argument to this command includes a forward-path
(normally a mailbox and domain, always surrounded by "<" and ">"
brackets) identifying one recipient. If accepted, the SMTP server
returns a 250 OK reply and stores the forward-path. If the recipient
is known not to be a deliverable address, the SMTP server returns a
550 reply, typically with a string such as "no such user - " and the
mailbox name (other circumstances and reply codes are possible).
This step of the procedure can be repeated any number of times.

https://github.com/zendframework/zend-mail/blob/master/src/Transport/Smtp.php#L224-L261
https://github.com/zendframework/zend-mail/blob/master/src/Protocol/Smtp.php#L285-L294
https://github.com/zendframework/zend-mail/blob/master/src/Protocol/AbstractProtocol.php#L326-L354

The email should be sent

Is it a problem in the smtp implementation ?

What do you think ?

I did a test with TELNET.

Connected to XXXXXXXXXXX
Escape character is '^]'.
220 xx.xxxxx.xx ESMTP (Ubuntu)
EHLO
501 Syntax: EHLO xxxxxx
EHLO xxxx
250-xx.xxxxx.xx
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
VRFY [email protected]
252 2.0.0 [email protected]
VRFY [email protected]
550 5.1.1 <[email protected]>: Recipient address rejected: User unknown in local recipient table
MAIL FROM: [email protected]
250 2.1.0 Ok
RCPT TO: [email protected]
250 2.1.5 Ok
RCPT TO: [email protected]
550 5.1.1 <[email protected]>: Recipient address rejected: User unknown in local recipient table
data
354 End data with <CR><LF>.<CR><LF>
Subject: test

Test
.
250 2.0.0 Ok: queued as 29AD1D60596
quit
221 2.0.0 Bye
Connection closed by foreign host.

=> some recipients in error BUT email is sent


Originally posted by @MadCat34 at zendframework/zend-mail#178

Return-Path Email is not used

Description

E-mail Return-Path is not set correctly because it only uses the last forced e-mail address, so as workaround I implemented this code change to give priority to the e-mail address that is already stored in the parameters and therefore the return path mail will be set correctly.

E.g. $parameters = " '-f [email protected]' '-f [email protected]'";
It will use '[email protected]' as return path email.

Magento 2.3.0 Alpha: steps to reproduce

 1 - Admin store: Stores > Settings > Configuration > Advanced > System > Mail Sending Settings > Return-Path Email - set a different return path email
 2 - Place an order
 3 - Look for ´Return-Path: <new return path email>' in the email

Originally posted by @Filipe-Bicho at zendframework/zend-mail#215

Infinite imap decodeLine while loop

I just got a case where a line as follows: [LIST (\HasNoChildren) "/" {54} caused the while loop to run indefinitely.

I suspect ist this space character appended, which will cause the while (($pos = strpos($line, ' ')) !== false) { to run indefinitely? Not a nice thing to happen ^^ .

https://github.com/zendframework/zend-mail/blob/ece418b37aaf8a98c991d7f0c198408043a2172d/src/Protocol/Imap.php#L217

Im guessing {54} is a prefix to say that the next 54 Characters could contain special chars: (in my case Aufgaben/to dos/Landingpage "meine Immobilie im Alter". It probably meant the quotes.

It seams to work when I remove the space on L217.


Originally posted by @jensstalder at zendframework/zend-mail#240

Transport service factory

There is missing service factory for mail transports like same in db and other components.

production config/autoload/local.php

return [
    'mail' => [
        'transport' => [
            'type'    => 'smtp',
            'options' => [
                'host'              => 'smtp.example.com',
                'connection_class'  => 'login',
                'connection_config' => [
                    'username' => '[email protected]',
                    'password' => 'xxxxxxxx',
                    'ssl'      => 'tls'
                ],
            ],
        ],
    ],
];

testing / dev config/autoload/local.php

return [
    'mail' => [
        'transport' => [
            'type'    => 'in-memory'
        ],
    ],
];

That is may look like https://github.com/autowp/zf-components/blob/master/src/Mail/Transport/TransportServiceFactory.php


Originally posted by @autowp at zendframework/zend-mail#120

Email with special character

zend-mail:2.5.2
vendor/zendframework/zend-mail/src/Header/HeaderValue.php:112
method Zend\Mail\Header\HeaderValue::assertValid($value) throws RuntimeException - Invalid header value detected validation e-mail: ً [email protected]. Please pay attention that email contains symbol https://en.wiktionary.org/wiki/%D9%8B. But zend-validator EmailAddress considered this email valid. I can not understand which side of the error


Originally posted by @r-erema at zendframework/zend-mail#221

authentication rejected, but nothing shows in tcpdump

I am having this issue... the most similar thing seems to be #170 (in that i can't xdebug and would like to see/debug the communication at protocol level to have a clearer idea) but in my case using tcpdump on port 25 does not show anything... yet there is a smtp protocol error and that baffles me...

I am using espocrm so full code is open source. also here

This is my stack trace. Looks like bad credentials but webmail login works ok in cpanel (it's centos 7.6)...

Zend\Mail\Protocol\Exception\RuntimeException: 5.7.0 ...authentication rejected
 in /home/foo/public_html/crm/vendor/zendframework/zend-mail/src/Protocol/AbstractProtocol.php:348
Stack trace:
#0 /home/foo/public_html/crm/vendor/zendframework/zend-mail/src/Protocol/Smtp/Auth/Login.php(78): Zend\Mail\Protocol\AbstractProtocol->_expect(Array)
#1 /home/foo/public_html/crm/vendor/zendframework/zend-mail/src/Protocol/Smtp.php(222): Zend\Mail\Protocol\Smtp\Auth\Login->auth()
#2 /home/foo/public_html/crm/vendor/zendframework/zend-mail/src/Transport/Smtp.php(401): Zend\Mail\Protocol\Smtp->helo('vps.me.com')
#3 /home/foo/public_html/crm/vendor/zendframework/zend-mail/src/Transport/Smtp.php(383): Zend\Mail\Transport\Smtp->connect()
#4 /home/foo/public_html/crm/vendor/zendframework/zend-mail/src/Transport/Smtp.php(394): Zend\Mail\Transport\Smtp->lazyLoadConnection()
#5 /home/foo/public_html/crm/vendor/zendframework/zend-mail/src/Transport/Smtp.php(251): Zend\Mail\Transport\Smtp->connect()
#6 /home/foo/public_html/crm/application/Espo/Core/Mail/Sender.php(397): Zend\Mail\Transport\Smtp->send(Object(Zend\Mail\Message))
#7 /home/foo/public_html/crm/custom/Espo/Custom/Services/Email.php(116): Espo\Core\Mail\Sender->send(Object(Espo\Entities\Email), Array, Object(Zend\Mail\Message))
#8 /home/foo/public_html/crm/application/Espo/Services/Email.php(324): Espo\Custom\Services\Email->send(Object(Espo\Entities\Email))

I can't find a log for any of this nowhere... can someone suggest some paths that could help?

Thansk


Originally posted by @beppe9000 at zendframework/zend-mail#241

Zend Mail does not conform with RFC2822 by not accepting content which contains additional extra lines.

  • [✅] I was not able to find an open or closed issue matching what I'm seeing.
  • [✅] This is not a question. (Questions should be asked on chat (Signup here) or our forums.)

Spamassassin in cPanel seems to be appending an X-Ham-Report header to emails which Zend Mail can't handle properly due to the existence of additional extra lines.

In our opinion this seems to be a rather over-zealous interpretation of RFC2822:

Earlier versions of this standard allowed for different (usually more
liberal) syntax than is allowed in this version. Also, there have
been syntactic elements used in messages on the Internet whose
interpretation have never been documented. Though some of these
syntactic forms MUST NOT be generated according to the grammar in
section 3, they MUST be accepted and parsed by a conformant receiver.

This section documents many of these syntactic elements. Taking the
grammar in section 3 and adding the definitions presented in this
section will result in the grammar to use for interpretation of
messages.

(Emphasis mine)

Example to follow.

Code to reproduce the issue

$rawMessage = <<<MESSAGE
Return-Path: <>
Delivered-To: [email protected]
Received: from web02.dragonbyte-tech.com
    by web02.dragonbyte-tech.com with LMTP id QOusMegHf1veawAAmma+EA
    for <[email protected]>; Thu, 23 Aug 2018 20:15:52 +0100
Return-path: <>
Envelope-to: [email protected]
Delivery-date: Thu, 23 Aug 2018 20:15:52 +0100
Received: from a7-14.smtp-out.eu-west-1.amazonses.com ([54.240.7.14]:37364)
    by web02.dragonbyte-tech.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-SHA256:128)
    (Exim 4.91)
    id 1fsv5E-000794-0G
    for [email protected]; Thu, 23 Aug 2018 20:15:52 +0100
From: [email protected]
To: [email protected]
Message-ID: <0102016568364366-a3538a5d-dbce-449b-9af3-efc8a9606a34-000000@eu-west-1.amazonses.com>
Subject: Delivery Status Notification (Failure)
MIME-Version: 1.0
Content-Type: multipart/report; 
    boundary="----=_Part_382740_1809377826.1535051711352"; 
    report-type=delivery-status
Date: Thu, 23 Aug 2018 19:15:11 +0000
X-SES-Outgoing: 2018.08.23-54.240.7.14
X-Spam-Status: No, score=0.0
X-Spam-Score: 0
X-Spam-Bar: /
X-Ham-Report: Spam detection software, running on the system "web02.dragonbyte-tech.com",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 root\@localhost for details.
 
 Content preview:  An error occurred while trying to deliver the mail to the
   following recipients: [email protected] lery, in order to complete
    your registration or reactivate your account at DragonByte Tech | X
 
 Content analysis details:   (0.0 points, 5.0 required)
 
  pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -0.0 RCVD_IN_DNSWL_NONE     RBL: Sender listed at http://www.dnswl.org/, no
                             trust
                             [54.240.7.14 listed in list.dnswl.org]
  0.0 HTML_MESSAGE           BODY: HTML included in message
 -0.0 BAYES_20               BODY: Bayes spam probability is 5 to 20%
                             [score: 0.1726]
X-Spam-Flag: NO

------=_Part_382740_1809377826.1535051711352
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Description: Notification

An error occurred while trying to deliver the mail to the following recipients:
[email protected]
------=_Part_382740_1809377826.1535051711352
Content-Type: message/delivery-status
Content-Transfer-Encoding: 7bit
Content-Description: Delivery Status Notification

Reporting-MTA: dsn; a4-1.smtp-out.eu-west-1.amazonses.com

Action: failed
Final-Recipient: rfc822; [email protected]
Diagnostic-Code: smtp; 554 delivery error: dd This user doesn't have a yahoo.com account ([email protected]) [0] - mta4348.mail.ne1.yahoo.com
Status: 5.3.0


------=_Part_382740_1809377826.1535051711352
Content-Type: message/rfc822
Content-Description: Undelivered Message

Message-ID: <0102016568363c3e-3d406e9f-3e9c-436f-b0dd-3217ee47f9cb-000000@eu-west-1.amazonses.com>
Date: Thu, 23 Aug 2018 19:15:09 +0000
Subject: DragonByte Tech | XenForo and vBulletin Mods & Addons - Account
 confirmation required
From: DragonByte Tech | XenForo and vBulletin Mods & Addons
 <[email protected]>
To: lery <[email protected]>
MIME-Version: 1.0
Content-Type: multipart/alternative;
 boundary="_=_swift_v4_1535051709_d92649e2095eedb18835fa1aec9983a5_=_"
X-To-Validate: [email protected]
X-SES-Outgoing: 2018.08.23-54.240.4.3
Feedback-ID: 1.eu-west-1.rqFLe/K6Rujqlv0M0C8a4TCJipFLr43+F05d3mJRahs=:AmazonSES
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple;
    s=uku4taia5b5tsbglxyj6zym32efj7xqv; d=amazonses.com; t=1535051709;
    h=Message-ID:Date:Subject:From:To:MIME-Version:Content-Type:Feedback-ID;
    bh=mCG0qMdQ/AUskt/Z/ABLfJl5lil6VxPg4UB+ky7cqMY=;
    b=QjLq5b76bEbznuPhO9fupk97DdUtOEvBA8oDnbKX9nQKxddC+/7/h8T9RVugLvsI
    BDMcUOgem4VWZ8KgNxihM8fvn4RBQDYezEFn+UzRU6ZFHmBEaE6kOdKpH58yphBXCWh
    mutZyghTbBUVP9BuNAIKR4FLFxhK8DjI8j6oX6Gg=


--_=_swift_v4_1535051709_d92649e2095eedb18835fa1aec9983a5_=_
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

lery, in order to complete your registration or reactivate your account at =
DragonByte Tech | XenForo and vBulletin Mods & Addons (https://www.dragonby=
te-tech.com/), you need to confirm your email address by clicking the butto=
n below.

Confirm your email (https://www.dragonbyte-tech.com/account-c=
onfirmation/lery.21958/email?c=3DfhxRsJXN6rsldFz8)

-------------------=
----------

Visit DragonByte Tech | XenForo and vBulletin Mods & Addons=
: https://www.dragonbyte-tech.com/

--_=_swift_v4_1535051709_d92649e2095eedb18835fa1aec9983a5_=_
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE html>
<html lang=3D"en-US" dir=3D"LTR">
<head>
=09<meta htt=
p-equiv=3D"Content-Type" content=3D"text/html; charset=3Dutf-8">
=09<base=
 href=3D"https://www.dragonbyte-tech.com/">
=09<meta name=3D"viewport" co=
ntent=3D"width=3Ddevice-width, initial-scale=3D1">
=09<meta http-equiv=3D=
"X-UA-Compatible" content=3D"IE=3Dedge">
=09<meta name=3D"format-detectio=
n" content=3D"telephone=3Dno">
=09<title>DragonByte Tech | XenForo and vB=
ulletin Mods &amp; Addons - Account confirmation required</title>
</head>=

<body dir=3D"LTR" leftmargin=3D"0" topmargin=3D"0" marginwidth=3D"0" mar=
ginheight=3D"0" style=3D"margin: 0; padding: 0; word-wrap: break-word; -ms-=
text-size-adjust: 100%; -webkit-text-size-adjust: 100%; background-color: #=
f0f1f3; font-size: 15px; font-family: 'Segoe UI','Helvetica Neue',Helvetica=
,Roboto,Oxygen,Ubuntu,Cantarell,'Fira Sans','Droid Sans',sans-serif; line-h=
eight: 1.4; color: #141414;">

<table id=3D"bodyTable" border=3D"0" wid=
th=3D"100%" height=3D"100%" cellpadding=3D"0" cellspacing=3D"0" style=3D"bo=
rder-spacing: 0; mso-table-lspace: 0pt; mso-table-rspace: 0pt; border-colla=
pse: collapse; height: 100% !important; width: 100% !important; margin: 0; =
padding: 0; background-color: #f0f1f3;">
<tr>
=09<td align=3D"center" v=
align=3D"top" id=3D"bodyTableContainer" style=3D"border-collapse: collapse;=
 background-color: #f0f1f3;">
=09=09<table border=3D"0" width=3D"600" cel=
lpadding=3D"0" cellspacing=3D"0" class=3D"container" dir=3D"LTR" style=3D"b=
order-spacing: 0; mso-table-lspace: 0pt; mso-table-rspace: 0pt; border-coll=
apse: collapse; width: 100%; max-width: 600px;">
=09=09<tr>
=09=09=09<t=
d class=3D"header" align=3D"center" valign=3D"top" style=3D"border-collapse=
: collapse; color: #444e50; padding: 6px 10px; border-top-left-radius: 4px;=
 border-top-right-radius: 4px; font-family: 'Segoe UI','Helvetica Neue',Hel=
vetica,Roboto,Oxygen,Ubuntu,Cantarell,'Fira Sans','Droid Sans',sans-serif; =
font-size: 24px; line-height: 1.4;">
=09=09=09=09<a href=3D"https://www.d=
ragonbyte-tech.com/" style=3D"color: #444e50; text-decoration: none;">Drago=
nByte Tech | XenForo and vBulletin Mods &amp; Addons</a>
=09=09=09</td>=

=09=09</tr>
=09=09<tr>
=09=09=09<td class=3D"content" align=3D"left"=
 valign=3D"top" style=3D"border-collapse: collapse; background-color: #fefe=
fe; border-radius: 2px; color: #141414; padding: 10px; font-size: 15px; fon=
t-family: 'Segoe UI','Helvetica Neue',Helvetica,Roboto,Oxygen,Ubuntu,Cantar=
ell,'Fira Sans','Droid Sans',sans-serif; line-height: 1.4;">

<p style=
=3D"margin-top: 0;">lery, in order to complete your registration or reactiv=
ate your account at <a href=3D"https://www.dragonbyte-tech.com/" style=3D"c=
olor: #2577b1; text-decoration: none;">DragonByte Tech | XenForo and vBulle=
tin Mods &amp; Addons</a>, you need to confirm your email address by clicki=
ng the button below.</p>

<p style=3D"margin-bottom: 0;"><a href=3D"htt=
ps://www.dragonbyte-tech.com/account-confirmation/lery.21958/email?c=3DfhxR=
sJXN6rsldFz8" class=3D"button" style=3D"color: #f0f1f3; text-decoration: no=
ne; display: inline-block; padding: 5px 10px; background-color: #2b3335; bo=
rder: none; border-radius: 4px; font-size: 13px;">Confirm your email</a></p=
>

=09=09=09</td>
=09=09</tr>
=09=09<tr>
=09=09=09<td class=3D"fo=
oter" align=3D"center" valign=3D"top" style=3D"border-collapse: collapse; p=
adding: 6px 10px; text-align: center; color: #8c8c8c; font-size: 13px; font=
-family: 'Segoe UI','Helvetica Neue',Helvetica,Roboto,Oxygen,Ubuntu,Cantare=
ll,'Fira Sans','Droid Sans',sans-serif; line-height: 1.4;">
=09=09=09=09<=
div><a href=3D"https://www.dragonbyte-tech.com/" style=3D"color: #8c8c8c; t=
ext-decoration: underline;">Visit DragonByte Tech | XenForo and vBulletin M=
ods &amp; Addons</a></div>

=09=09=09=09
=09=09=09</td>
=09=09</tr>=

=09=09</table>
=09</td>
</tr>
</table>

</body>
</html>

--_=_swift_v4_1535051709_d92649e2095eedb18835fa1aec9983a5_=_--


------=_Part_382740_1809377826.1535051711352--
MESSAGE;

$message = new \Zend\Mail\Storage\Message(['raw' => $rawMessage]);

Expected results

We can see the expected results if we change L80 of Header.php from:

if (preg_match('/^\s*$/', $line)) {

To:

if ($line === '') {

In which case, the following is the resulting headers:

array:18 [▼
  "Return-Path" => "<>"
  "Delivered-To" => "[email protected]"
  "Received" => "from a7-14.smtp-out.eu-west-1.amazonses.com ([54.240.7.14]:37364) by web02.dragonbyte-tech.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-SHA256:128) (Exim 4.91) id 1fsv5E-000794-0G for [email protected]; Thu, 23 Aug 2018 20:15:52 +0100"
  "Envelope-To" => "[email protected]"
  "Delivery-Date" => "Thu, 23 Aug 2018 20:15:52 +0100"
  "From" => "[email protected]"
  "To" => "[email protected]"
  "Message-ID" => "<0102016568364366-a3538a5d-dbce-449b-9af3-efc8a9606a34-000000@eu-west-1.amazonses.com>"
  "Subject" => "Delivery Status Notification (Failure)"
  "MIME-Version" => "1.0"
  "Content-Type" => """
    multipart/report;\r\n
     boundary="----=_Part_382740_1809377826.1535051711352";\r\n
     report-type="delivery-status"
    """
  "Date" => "Thu, 23 Aug 2018 19:15:11 +0000"
  "X-SES-Outgoing" => "2018.08.23-54.240.7.14"
  "X-Spam-Status" => "No, score=0.0"
  "X-Spam-Score" => null
  "X-Spam-Bar" => "/"
  "X-Ham-Report" => "Spam detection software, running on the system "web02.dragonbyte-tech.com", has NOT identified this incoming email as spam.  The original message has been attached to this so you can view it or label similar future email.  If you have any questions, see root\@localhost for details.  Content preview:  An error occurred while trying to deliver the mail to the following recipients: [email protected] lery, in order to complete your registration or reactivate your account at DragonByte Tech | X  Content analysis details:   (0.0 points, 5.0 required)  pts rule name              description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE     RBL: Sender listed at http://www.dnswl.org/, no trust [54.240.7.14 listed in list.dnswl.org] 0.0 HTML_MESSAGE           BODY: HTML included in message -0.0 BAYES_20               BODY: Bayes spam probability is 5 to 20% [score: 0.1726]"
  "X-Spam-Flag" => "NO"
]

Actual results

An exception occurred: [Zend\Mail\Exception\RuntimeException] Malformed header detected in src/vendor/zendframework/zend-mail/src/Headers.php on line 88

Zend\Mail\Headers::fromString() in src/vendor/zendframework/zend-mime/src/Decode.php at line 141
Zend\Mime\Decode::splitMessage() in src/vendor/zendframework/zend-mail/src/Storage/Part.php at line 99
Zend\Mail\Storage\Part->__construct() in src/vendor/zendframework/zend-mail/src/Storage/Message.php at line 54
Zend\Mail\Storage\Message->__construct() in test.php at line 227

Is this a change you would be willing to accept, or is there a reason not to accept the header formatting in this case?


Originally posted by @chrisdeeming at zendframework/zend-mail#218

POP3 getMessage fails with 'Line "<==UUID==>" does not match header format'

We are using zend-mail to fetch emails via POP3 and IMAP.
For integration tests, we run an instance of Flying Rat (https://pypi.org/project/flyingrat/) to mock a mail server with POP3. We build multipart emails in Python using MIMEMultipart and send them to the server via smtplib (all standard code used there, nothing fancy).

Now when I try to fetch the emails in zend-mail via getMessage(), it fails with the following exception::

Line "--===============0544532757501787723==" does not match header format!
vendor/zendframework/zend-mail/src/Storage/Part.php(112):   Zend\Mail\Headers::fromString('MIME-Version: 1...')
vendor/zendframework/zend-mail/src/Storage/Message.php(56): Zend\Mail\Storage\Part->__construct(Array)
vendor/zendframework/zend-mail/src/Storage/Pop3.php(63): Zend\Mail\Storage\Message->__construct(Array)
ourclass.php(298): Zend\Mail\Storage\Pop3->getMessage(1)

I have tried to debug this and printed out the $params in Message.php _construct.
It looks to me like zend-mail is not able to parse the headers correctly because Flying Rat does not support the TOP command and so the whole message is downloaded. Could this be a bug?

Here is the full debug output of the $params::

 (
     [handler] => Zend\Mail\Storage\Pop3 Object
         (
             [protocol:protected] => Zend\Mail\Protocol\Pop3 Object
                 (
                     [hasTop] =>
                     [socket:protected] => Resource id #9
                     [timestamp:protected] =>
                 )

             [has:protected] => Array
                 (
                     [uniqueid] =>
                     [delete] =>
                     [create] =>
                     [top] =>
                     [fetchPart] =>
                     [flags] =>
                 )

             [iterationPos:protected] => 0
             [iterationMax:protected] =>
             [messageClass:protected] => Zend\Mail\Storage\Message
         )

     [id] => 2
     [headers] => Content-Type: multipart/alternative;
  boundary="===============0544532757501787723=="
 MIME-Version: 1.0
 To: [email protected]
 From: [email protected]
 Subject: Test Url in Text
 Message-Id: <[email protected]>

 --===============0544532757501787723==
 Content-Type: text/plain; charset="us-ascii"
 MIME-Version: 1.0
 Content-Transfer-Encoding: 7bit

 No URL here
 --===============0544532757501787723==
 Content-Type: text/html; charset="us-ascii"
 MIME-Version: 1.0
 Content-Transfer-Encoding: 7bit

 https://example.net
 --===============0544532757501787723==--

     [noToplines] => 1
 )

Originally posted by @abulhol at zendframework/zend-mail#245

Email Attachments

I use Zend in ESPOCRM but i have been having issues with receiving attachments from some users the attachments still remain on the email server but they do not make it in the import any help would be great

this is the error it kicks out in the raw email

Line "-0700 (PDT)"does not match header format!

ESPOcrm 4.2.5
Ubuntu 14.04 LTS
Apache/2.4.7 (Ubuntu)
Zend 2.5.2 - 2015-09-10


Originally posted by @RCFilm at zendframework/zend-mail#114

Drop dependency on zendframework/zend-loader

This removes the dependency on the zendframework/zend-load package, as suggested in #185

The HeaderLoader class has been removed and replaced by a simple class map in the Headers class.

However, I have also removed the getPluginClassLoader and setPluginClassLoader methods. Since they are public, this might be a BC break. What do you think?


Originally posted by @acelaya at zendframework/zend-mail#186

Unable to connect via TLS

I have a problem when I send mail to client to Reset Password. I using Gmail

Warning: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in C:\wamp64\www\zend2112\vendor\zendframework\zend-mail\src\Protocol\Smtp.php on line 216

Here is my function:

function sendMailWithToken($user){
        $token = $user->getToken();
        $http = isset($_SERVER['https']) ? 'https://': "http://";
        $domail = $_SERVER['HTTP_HOST'];
        $link = $http.$domail.'/zend/public/set-password/'.$token;

        $messageBody = "Hello ".$user->getFullname(). ',\n';
        $messageBody.="Click the LINK below to reset your password: \n";
        $messageBody.=$link;
        $messageBody.=".\nThanks and Best Regards!";

        $html = new MimePart($messageBody);
        $html->type = "text/html";

        $body = new MimeMessage();
        $body->setParts(array($html));


        $message = new Message();
        $message->setEncoding("UTF-8");
        $message->addFrom('[email protected]', 'Forget Password');
        $message->addTo($user->getEmail());
        $message->setSubject('Forget Password');
        $message->setBody($body);

        // Setup SMTP transport
        $transport = new SmtpTransport();
        $options   = new SmtpOptions([
            'name' => 'smtp.gmail.com',
            'host' => 'smtp.gmail.com',
            'port' => 587,
            'connection_class'=>'login',
            'connection_config'=>[
                'username' =>'[email protected]',
                'password' => 'password',
                'ssl'      => 'tls',
                
            ],           
        ]);
        $transport->setOptions($options);
        $transport->send($message);
    }

Thanks for reading. I try to fix 2 days. Please help !!!


Originally posted by @phantien94 at zendframework/zend-mail#202

ListParser::parse parses string incorrectly

Code to reproduce the issue

include "vendor\zendframework\zend-mail\src\Header\ListParser.php"
var_dump(\Zend\Mail\Header\ListParser::parse("\"a'b\" <[email protected]>, def <[email protected]>"));

Expected results

array(2) {
[0]=>
string(19) ""a'b" [email protected]"
[1]=>
string(18) " def [email protected]"
}

Actual results

array(1) {
[0]=>
string(38) ""a'b" [email protected], def [email protected]"
}

Solution

Add the following else-if branch under the current one.
Rationale: if you're in a quoted-string, don't look for more quotes as they're part of the comment.

            if ($char === $currentQuoteDelim) {
                $inQuote = false;
                $currentQuoteDelim = null;
                continue;
            }
            // We are in a quote, but encountered another quote-char: don't do anything.
            else if ( $inQuote ) {
              continue;
            }

Originally posted by @svaningelgem at zendframework/zend-mail#222

Problems with mailadress parsing

Example Email-header:
"Foo <bar" [email protected]

Description:
The example email-header should be valid according to https://tools.ietf.org/html/rfc2822#section-3.4 but the function AdressList.php/addFromString matches it incorrect. The result has the following form:
"bar <[email protected]"
This is clearly not a valid adress and therefore causes exceptions in the following code

Solution:
Changing the regex in the addFromString function from lazzy to greedy by removing "?" from the named capture group "name"

  • old: ^((?P.*?)<(?P[^>]+)>|(?P.+))$
  • new: ^((?P.*)<(?P[^>]+)>|(?P.+))$

Originally posted by @Baztey at zendframework/zend-mail#127

Settings Return-Path Email is not used

  • I was not able to find an open or closed issue matching what I'm seeing.
  • This is not a question. (Questions should be asked on chat (Signup here) or our forums.)

Return-Path Email is not used because the php function mail($to, $subject, $message, $headers, $parameters) only uses the last forced email from the $parameters string and the method prepareParameters(Mail\Message $message) in the class zend-mail\src\Transport\Sendmail.php
adds a second forced parameter, so the mail() function only uses this second parameter and the desired return path email is ignored.

E.g. $parameters = " '-f [email protected]' '-f [email protected]'";
It will use '[email protected]' as return path email.

Code to reproduce the issue

$sender = $message->getSender();
        if ($sender instanceof AddressInterface) {
            $parameters .= ' -f' . \escapeshellarg($sender->getEmail());
            return $parameters;
        }

        $from = $message->getFrom();
        if (count($from)) {
            $from->rewind();
            $sender      = $from->current();
            $parameters .= ' -f' . \escapeshellarg($sender->getEmail());
            return $parameters;
        }

Magento 2.3.0 Alpha: steps to reproduce

1 - Admin store: Stores > Settings > Configuration > Advanced > System > Mail Sending Settings > Return-Path Email - set a different return path email
2 - Place an order
3 - Look for ´Return-Path: ' in the email

Expected results

return path email saved in settings

Actual results

sender or from email


Originally posted by @Filipe-Bicho at zendframework/zend-mail#216

Content-Type header handling

Hi

There is a case when emails have Content-Type header, defined with keyword "ContentType", for example:

ContentType: text/html; charset="UTF-8"

In this case error appears:

Invalid header line for Content-Type string

Looking header fieldName normalization, I see that Content-Type, Content_Type, Content Type, ContentType will be normalized to contenttype. So contenttype will be stored in Zend\Mail\Headers::$headersKeys and appropriate header in Zend\Mail\Headers::$headers.
Than on header loading pluginClassLoader will load Zend\Mail\Header\ContentType and method Zend\Mail\Header\ContentType::fromString() is called.
But there is condition that do not accept 'contenttype` value.

It looks like inconsistent behavior. I understand that rfc2045 accepts Content-Type keyword only, but in real cases other keywords can appear.


Originally posted by @hugeval at zendframework/zend-mail#107

tests: Mail\Message produced output not usable by Storage\Message

this shows the problem zend-mail is having:

mail created with Mail\Message and serialized into raw
and then loaded with Storage\Message causes parse error if the $text contains double unix newlines (\n\n).

        $text = "Hello, bödi tekst\n\nBye";

        $part = new Mime\Part($text);
        $part->type = 'text/plain';
        $part->charset = 'UTF-8';

        $mime = new Mime\Message();
        $mime->addPart($part);

        $message = new Mail\Message();
        $message->setEncoding('UTF-8');
        $message->setBody($text);

        $raw = $message->toString();
        $message = new Storage\Message(['raw' => $raw]);

this throws on $message = new Storage\Message(['raw' => $raw]);

`


Originally posted by @glensc at zendframework/zend-mail#159

Consider removing dependency on zend-loader

I have seen that this package requires zendframework/zend-loader, just for one class, the Zend\Mail\Header\HeaderLoader.

However, this class basically defines a map to resolve header names to class names.

Would you be open to replace this by a simple array map in the Zend\Mail\Headers class? This would let us drop the requirement on zendframework/zend-loader (assuming I'm not missing anything...).

I could do it if you want.


Originally posted by @acelaya at zendframework/zend-mail#185

Properly encode content-disposition header

Provide a narrative description of what you are trying to accomplish:

  • Are you fixing a bug?
    • Detail how the bug is invoked currently.
    • Detail the original, incorrect behavior.
    • Detail the new, expected behavior.
    • Base your feature on the master branch, and submit against that branch.
    • Add a regression test that demonstrates the bug, and proves the fix.
    • Add a CHANGELOG.md entry for the fix.

Always use ASCII for the content-disposition header. When using UTF-8 encoding, this results in a header being set as Content-Disposition: =?utf-8?Q?inline?= which is not interpreted properly by Thunderbird nor Microsoft Exchange / Outlook. This pull request forces encoding for this header to always be ASCII, so that the header reads Content-Disposition: inline and is correctly interpreted by email clients.

Fixes: magento/magento2#25076


Originally posted by @fredden at zendframework/zend-mail#251

Add JMAP support (as an alternative to IMAP + SMTP, and later to CardDAV/CalDAV)

"JMAP is intended to be a new standard for email clients to connect to
mail stores. It therefore intends to primarily replace IMAP + SMTP
submission. It is also designed to be more generic such that it can be
extended with contacts, calendars in the future (replacing
CardDAV/CalDAV). It does not replace MTA-to-MTA SMTP transmission."

http://jmap.io/

You may wonder "Who uses or supports it?"

Cyrus IMAP and Apache James are the notable ones here:
http://jmap.io/software.html

OpenPaaS is an open source Entreprise Social Platform which is led by
LINAGORA (which has more than 150 employees)
https://linagora.com/
http://www.open-paas.org

OpenPaaS is using Apache James. And you can see JMAP used in the code:
https://github.com/linagora/openpaas-esn/search?utf8=%E2%9C%93&q=jmap&type=

In this video: https://www.youtube.com/watch?v=2QZIi3EO6rQ , Benoit
Tellier explains why they decided to invest in James and JMAP (among
other things). LINAGORA has 5 full time employees which are devoted to
the project.

Why LINAGORA picked JMAP:
https://medium.com/linagora-engineering/you-cant-do-imap-in-the-browser-can-you-208838b0ba17
https://medium.com/linagora-engineering/openpaas-newsletter-march-2018-c0a3e469e83e
https://medium.com/linagora-engineering/openpaas-is-out-773704eadfbc

FastMail started this initiative:
"JMAP is FastMail's protocol with the warts removed. We leverage
existing standards like HTTP, JSON, and native push channels on
platforms which have them - making it easy for developers to work with."
https://blog.fastmail.com/2016/12/22/cyrus-development-and-release-plans/
https://blog.fastmail.com/2016/12/12/why-we-contribute/
https://blog.fastmail.com/2016/12/09/jmap-test-suite/
https://blog.fastmail.com/2015/12/23/the-jmap-momentum-builds/
https://blog.fastmail.com/2015/08/11/an-open-source-jmap-proxy-javascript-library-and-webmail-demo/
https://blog.fastmail.com/2014/12/23/jmap-a-better-way-to-email/

Roundcube Next will support JMAP as well.
https://github.com/search?q=org%3Aroundcube-next+jmap&type=Code

Thanks!


Originally posted by @marclaporte at zendframework/zend-mail#201

How to migrate from Zend 1.0???

Hey,
I don't know what to do. My boss told me to migrate our Zend 1 applications to current Zend-Mail (or Laminas) without touching any source code (because this would be too much work). Maybe with a wrapper-class or whatever... In the best case we would like to migrate to composer as well but that seems to be too difficult without touching projects.

Our folder looks like this

  • Project X
    ->src
  • Project X2
    ->src
  • Project X3
    ->src
  • Zend-Mail-Framework

Maybe you've got an idea. Our version is round'about November 2011?!?

Thanks anyway
~Tim

Windows 10/PHP7 Lone CR/LF Exception

On my windows 10/PHP 7 box I'm getting this error. This error does not effect our dev/production unix servers.

Unable to send mail: mail(): SMTP server response: 550 5.6.0 Lone CR or LF in headers (see RFC2822 section 2.2)

I don't think there is anything wrong with the code that is simply rendering a template.

$viewRenderer = $this->getServiceLocator()->get('ViewRenderer');

$content = $viewRenderer->render($template, $data);

$html = new MimePart($content);
$html->type = Mime::TYPE_HTML;
$html->charset = 'utf-8';
$html->encoding = Mime::ENCODING_8BIT;

$body = new MimeMessage();
$body->setParts([$html]);

$message = new Message();
$message->setSubject($data['subject']);
$message->setBody($body);
$message->setTo($data['to']);
$message->setFrom($config['noreply']['email'], $config['noreply']['name']);
$message->setEncoding('UTF-8');

$transport = new Sendmail();

$transport->send($message);

Originally posted by @tomshaw at zendframework/zend-mail#115

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.