OpenMage / magento-lts

Official OpenMage LTS codebase | Migrate easily from Magento Community Edition in minutes! Download the source code for free or contribute to OpenMage LTS | Security vulnerability patches, bug fixes, performance improvements and more.
https://www.openmage.org
Open Software License 3.0
865 stars 438 forks source link

support smtp servers out of the box #3939

Open ioweb-gr opened 2 months ago

ioweb-gr commented 2 months ago

Description (*)

Currently there's a huge email deliverability issue with default openmage because it's not using SMTP to send the emails, usually they're not signed with DKIM and end up in spam if you're lucky. Other solutions like aschroeder/smtp_pro don't work with website level configurations and are basically not updated for 10 years. If this platform is going to stay, it needs to have it's own compatibility layer with SMTP connections in my opinion.

Expected behavior (*)

The system should be able to send via SMTP and not only via sendmail

Benefits

It would improve email deliverability and security.

Additional information

fballiano commented 2 months ago

why smtppro doesn't work for you? I've have on a lot of stores on v20/php8.3 and works perfectly

fballiano commented 2 months ago

ah you mean that you can't configure a different smtp for every website? but the emails are correctly sent with the proper "from email address" depending on the store

ioweb-gr commented 2 months ago

First of all if you check the configuration options scopes, they're set to website = 0 so they won't work for multi-site, but we can patch this.

Secondly, after setting it up it throws this error for TLS on 587

        if ($this->_secure == 'tls') {
            $this->_send('STARTTLS');
            $this->_expect(220, 180);
            if (!stream_socket_enable_crypto($this->_socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
                /**
                 * @see Zend_Mail_Protocol_Exception
                 */
                #require_once 'Zend/Mail/Protocol/Exception.php';
                throw new Zend_Mail_Protocol_Exception('Unable to connect via TLS');
            }
            $this->_ehlo($host);
        }

And that error for SSL on 465

        // open connection
        $this->_socket = @stream_socket_client($remote, $errorNum, $errorStr, self::TIMEOUT_CONNECTION);

        if ($this->_socket === false) {
            if ($errorNum == 0) {
                $errorStr = 'Could not open socket';
            }
            /**
             * @see Zend_Mail_Protocol_Exception
             */
            #require_once 'Zend/Mail/Protocol/Exception.php';
            throw new Zend_Mail_Protocol_Exception($errorStr);
        }

Granted the OpenMage version I tested this is low > OpenMage LTS 20.0.7 and using php 7.4 but still

I'm assuming it's not creating the stream context properly in each case causing the failure

ioweb-gr commented 2 months ago

ah you mean that you can't configure a different smtp for every website? but the emails are correctly sent with the proper "from email address" depending on the store

Regarding that, in most providers if you set a different from address than the defined smtp address it will either get overwritten or the mail will be rejected by amavis. So you need to have the same smtp email address as the one you're sending from.

Sometimes a single smtp connection is not enough so it woudl be a bonus to have multiple smtp connections tied to email addresses.

But in any case I was referring to it having some issues sending as well.

pquerner commented 2 months ago

I dont know much about the spec, but maybe its possible to not have Magento (PHP) do that but some different process on the host thats "made to do it"? This way we could save mbox (I think thats what they are called) files and that other process handles sending it?

fballiano commented 2 months ago

btw the platform is gonna survive if the people who use it participate, there is no big company paying for everybody here and there's too little participation or support. personally I work my ass off for free in order to still have something to provide to my customers, which, btw, don't pay me for the OM development but just to apply those improvements to their store.

So my suggestion is to submit a PR to aschroeder/smtp_pro because realistically we're not gonna be able to redevelop and merge something like that in the core.

fballiano commented 2 months ago

I'm seeing https://github.com/aschroder/Magento-SMTP-Pro-Email-Extension/pulls PRs are not processed at all.

Maybe we could fork it and merge those PRs, I don't know, I'm already working on so many things.

ioweb-gr commented 2 months ago

@fballiano First of all this is not meant to take it personally my friend.

I just see the issues as they arise and while I'm working on a solution I report them here as well. Whether they're bug reports or feature requests or anything I just put them here and see how we can proceed with them. Of course if I had found a solution I'd push it already but I haven't found it yet :)

Also I saw the same on the smtp pro extension, it's pretty much dead. No one cares about it that's why I thought this feature would be important in OpenMage.

Basically every other framework has smtp capabilities out of the box by now using symfony/mailer which is properly supported but because we have Zend ( 👎 ) we're stuck with all the issues it gives

fballiano commented 2 months ago

All I can say is that all of us should be the change that they want to be (well, this is a quote heheheh), everybody has to take something in his/her own responsibility and do what they need

Flyingmana commented 2 months ago

I did not read much of the comments. But if its a change which does not cause many problems with existing integrations, I dont see a big reason against accepting a PR, if you find/have someone who is going to provide this changes.

empiricompany commented 2 months ago

+1 for a PR that implements it. I would like to contribute. personally I use aschroder smtp that have some issues when email cannot be delivered and block entire queue also some limitation with from headers and multistore under different domains. this is my fork: https://github.com/empiricompany/Magento-SMTP-Pro-Email-Extension

alexh-swdev commented 2 months ago

We are using Advanced SMTP which, I see now, is also in OM module fostering https://github.com/OpenMageModuleFostering/artsonit_advancedsmtp

/Edit: And Sven Reichel also has a fork of it: https://github.com/sreichel/magento-ArtsOnIT_AdvancedSmtp