Magento 2 Extensions:Custom SMTP

From XTENTO Support Wiki
Jump to: navigation, search
This is a guide for Magento 2. This extension is a Magento 2 only extension, we don't offer a version for Magento 1 at this point.

Customsmtp.png
Buy-now.png

Contents

Overview

Take full control over email sending settings in Magento 2! Easily configure your SMTP settings in Magento 2, including ready-to-use settings for more than 27 providers, as well as the ability to debug email delivery issues and make sure emails are sent properly using the extensions built-in email log.

Interested in this Magento Extension?

Head over to our store to purchase this extension: Custom SMTP Settings (Magento 2)

Got questions? Feel free to contact us! Contact Form

Setting up the extension

The extensions configuration section is located at System > XTENTO > Custom SMTP. Make sure to enable the module there.

Then, either use one of the ready-to-use settings templates, or simply enter the SMTP details of your provider including username/password there. Then, scroll to the bottom and use the "Test" section to send a test email to yourself, to verify the settings. Then, save the configuration.

E-Mails will now be sent using the Custom SMTP extension.

Using the extension

If logging has been enabled in the modules configuration, simply go to Reports > E-Mail Log to check/look up any sent email.

Troubleshooting

OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed

This is a problem with your PHP configuration. See here for the solution: https://stackoverflow.com/questions/32019623/openssl-error-messages-error14090086ssl-routinesssl3-get-server-certificate

You will need to download the CA file and place it in the directory they state. Then add it to the php.ini file (you can find the "active" php.ini file using phpinfo()), then restart your webserver.

Make sure to properly set permissions as well, the /usr/ssl/certs/cacert.pem file should have chmod 755.

"Undefined / Timeout" while testing configuration

If you get a popup saying "Undefined / Timeout" when trying to test your SMTP configuration, there are two possible reasons:

1) Your server is behind a firewall. Your server cannot connect to the SMTP server and the connection times out. Contact your web hoster. Using SSH, you can verify/proof it like this: cat < /dev/tcp/smtp.gmail.com/25
cat < /dev/tcp/smtp.gmail.com/587
cat < /dev/tcp/smtp.gmail.com/465
If the connection works, you should see some kind of response and no timeout. Otherwise, a timeout/error message, proofing it's a firewall issue. Try it with your SMTP server/port as well.

2) This is probably caused by you having installed two SMTP extensions in your store. Make sure to remove any other SMTP extensions from third party vendors from your Magento installation, it doesn't make sense to have more than one SMTP extension in a Magento installation. For example, make sure to remove the MagePal_GmailSmtpApp extension.

"Client was not authenticated to send anonymous mail during MAIL FROM"

1) Double check the username and password. For example, Office 365 sometimes require the User ID including the domain name to be used, and not the actual email ID.
2) Enable "Override From" and make sure to use the email address that is allowed to send emails (same as login usually)

If this doesn't help: This is not an issue in our extension but rather the settings / your email provider. Consult with your email provider.

"Error while sending E-Mail: Syntax error in parameters or arguments"

This usually means one of the email headers is missing. If the "From" header is missing, you can simply enable "Override From Header" in the extensions configuration and set the correct from email address.

Only test emails are sent, no other emails are sent/logged

This means you have another extension installed that tries to set up SMTP settings in Magento. For example, a SMTP extension of another extension vendor. Make sure to remove such extensions from Magento before installing our extension. Also, we're aware of the "Dotmailer" Magento 2 extension (Dotdigitalgroup_Email) to also cause this issue, as it also sets up their own SMTP settings in Magento.

Error: "Connection Refused"

Trying to send an email and getting "Connection Refused"? Either the hostname/port of the SMTP server you specified is wrong, or if you are 100% sure it's right, this means YOUR server is blocking the request. Please contact your hosting provider, they may need to whitelist outgoing connections on that port in their firewall.

Error: "Could not open socket"

Two possible reasons:

WHM / cPanel + Failed SMTP connection

Using WHM / cPanel and cannot get emails to send? Maybe SMTP Restrictions have been enabled in WHM. Go to "WHM > Security Center > SMTP Restrictions" and disable this. Also, check "WHM > Server Configuration > Tweak Settings > Mail > Restrict outgoing SMTP to root, exim, and mailman (FKA SMTP Tweak)" and make sure this is disabled.

Gmail: Please log in via 5.7.14 your web browser and then try again.

See: https://stackoverflow.com/a/25238515

Uncaught Error: Call to undefined method Magento\Email\Model\Transport\Interceptor::testConfiguration()

Make sure "Module Enabled" is set to "Yes" and "Use Custom SMTP Settings" is set to "Yes" as well. Then click "Save Configuration". Then, try using the "Send Test E-Mail" button again.

SendGrid

One can use either their SendGrid.com website login credentials OR their API key:

Username: apikey
Password: API Key starting with "SG."

Error: 1408F10B:SSL routines:ssl3_get_record:wrong version number

I'm getting an error similar to: Could not open socket: stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages: error:1408F10B:SSL routines:ssl3_get_record:wrong version number

This could be caused by wrong connection security setting. Try setting "Connection Security" to TLS or SSL or the other way round.

Zend\Mail\Transport\Smtp transport expects either a Sender or at least one From address in the Message; none provided

Error: Error while sending E-Mail: Zend\Mail\Transport\Smtp transport expects either a Sender or at least one From address in the Message; none provided ...

That's a core issue in Magento actually. There are issues with the from email being empty: https://github.com/magento/magento2/issues/14952

Anyways, you can fix it by enabling "Override From" in our modules configuration and specifying a from email address. But then just one "From" email will be used. So, you will most likely need to apply the patches described in the link above, as it's a better solution.

Background information: Our extension cannot fix this core behavior of Magento - we are "just" the SMTP service, and the "email" that Magento gives us to send is already missing the "From" details.

Error: Invalid header value detected

This is a bug in Magento <=2.3.3 and should be fixed in Magento 2.3.4. For a (temporary) patch/fix see here: https://github.com/magento/magento2/pull/24906/files#diff-dfb3ee5a7f863458afea75f5524cd2e5

Removing a header from all messages

Let's say you want to remove the Content-Disposition header (added in Magento 2.3.3) from all emails. Open the file: app\code\Xtento\CustomSmtp\Model\CustomTransportM233.php

Look for:

$this->zendTransport->send(
    ZendMessage::fromString($this->message->getRawMessage())
);

BEFORE that line add:

$this->zendMessage->getHeaders()->removeHeader("Content-Disposition");

Error: authentication failed: UGFzc3dvcmQ6

Error message:

5.7.8 Error: authentication failed: UGFzc3dvcmQ6

This means the username/password you entered is wrong. If nothing helps, try changing the password of your email account to something more simple. Sometimes passwords without special characters have helped.

Warning: stream_socket_enable_crypto(): SSL: Connection reset by peer

You will please need to open a ticket with your SMTP email server provider/hoster. The error "connection reset by peer" clearly says that the remote server (SMTP server) is cutting the connection. It could be a firewall, or an issue with the remote SMTP server.

Error: STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied

Usually an issue with Office 365. Please check the sender address in your SMTP settings. The error message tells you that you are not allowed to send as the sender you are trying to use. This is often caused from using a wrong sender address in your Group or Notification config.

Personal tools
Namespaces
Variants
Actions
General Information
Magento 2 Guides
Magento 2 Extensions
Magento 1 Guides
Magento 1 Extensions
Magento Integration Suite
Product Feed Guides
Toolbox