0

We have a new Drupal 8 site and are having issues with the SMTP module. The account we are using to send email works successfully on our Drupal 7 sites and in other cases, but we cannot get it to work successfully on Drupal 8. I have also tried another Non-SSL account and am getting the same two messages over and over in the error log.

Error sending e-mail from [email protected] to [email protected]: SMTP Error: Could not connect to SMTP host.

Error sending email (from [email protected] to [email protected] with reply-to not set).

I have found many similar questions, but not a working solution yet. Any help would be greatly appreciated, thank you in advance!

2 Answers 2

1

Doh! It turns out this was not a Drupal issue, but a Centos issue with SELinux. I was able to check SELinx settings by running the following commands

getsebool httpd_can_sendmail

which returned

httpd_can_sendmail --> off

and

getsebool httpd_can_network_connect

returned

httpd_can_network_connect --> off

I enabled them by running this

setsebool -P httpd_can_sendmail 1

setsebool -P httpd_can_network_connect 1

And the Drupal SMTP module worked beautifully after that. Hopefully this helps someone else as well.

0

For Drupal 8 Install PHPMailer and SMTP: Go to the root of your Drupal 8 project and execute below to install and enable smtp module from Admin interface or via drush

composer require phpmailer/phpmailer
composer require drupal/smtp

Configure SMTP at: /admin/config/system/smtp

INSTALL OPTIONS

Set SMTP as the default mailsystem

On
When on, all mail is passed through the SMTP module.

SMTP SERVER SETTINGS

SMTP server

smtp.host.name
The address of your outgoing SMTP server.

SMTP backup server

The address of your outgoing SMTP backup server. If the primary server can't be found this one will be tried. This is optional.

SMTP port

25
The default SMTP port is 25, if that is being blocked try 80. Gmail uses 465. See 
http://gmail.google.com/support/bin/answer.py?answer=13287 for more information on 
configuring for use with Gmail.

Use encrypted protocol

No
This allows connection to an SMTP server that requires SSL encryption such as Gmail.

Enable TLS encryption automatically

On
Whether to enable TLS encryption automatically if a server supports it, even if the 
protocol is not set to "tls".

Timeout

60
Amount of seconds for the SMTP commands to timeout.

Turn on the SMTP keep alive feature
Enabling this option will keep the SMTP connection open instead of it being openned 
and then closed for each mail

SMTP AUTHENTICATION

Leave blank if your SMTP server does not require authentication.

Username

SMTP Username.

Password

SMTP password.

If you have already entered your password before, you should leave this field blank, unless you want to change the stored password. Please note that this password will be stored as plain-text inside Drupal's core configuration variables.

E-MAIL OPTIONS

E-mail from address
The e-mail address that all e-mails will be from.

E-mail from name
The name that all e-mails will be from. If left blank will use a default of: Portal 
Name . Some providers (such as Office365) may ignore this field. For more 
information, please check SMTP module documentation and your email provider 
documentation.

Allow to send e-mails formatted as HTML

Checking this box will allow HTML formatted e-mails to be sent with the SMTP protocol.

SMTP CLIENT SETTINGS

Hostname

[email protected]
The hostname to use in the Message-Id and Received headers, and as the default HELO 
string. Leave blank for using _.

HELO

Test
The SMTP HELO/EHLO of the message. Defaults to hostname (see above).

SEND TEST E-MAIL

E-mail address to send a test e-mail to
Type in an address to have a test e-mail sent there.

Enable debugging

Checking this box will print SMTP message

Enabling Debugging will help know the SMTP isssues, check the project page for other error refrences: https://www.drupal.org/project/smtp

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.