Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mailhog doesn't work with TYPO3 ddev configuration #924

Closed
spoonerWeb opened this issue Jun 15, 2018 · 17 comments
Closed

Mailhog doesn't work with TYPO3 ddev configuration #924

spoonerWeb opened this issue Jun 15, 2018 · 17 comments
Assignees
Milestone

Comments

@spoonerWeb
Copy link
Contributor

spoonerWeb commented Jun 15, 2018

Describe the bug
TYPO3 in its basic configuration cannot send test mails due to an error in the sendmail command: /usr/local/bin/mailhog sendmail test@example.org --smtp-addr 127.0.0.1:1025

To Reproduce
Steps to reproduce the behavior:

  1. Setup TYPO3
  2. Go to Install Tool (/typo3/install.php)
  3. Go to module Environment
  4. Go to Test Mail Setup
  5. Send a test mail
  6. Error Something went wrong, in the TYPO3 log Uncaught TYPO3 Exception: Unsupported sendmail command flags [/usr/local/bin/mailhog sendmail test@example.org --smtp-addr 127.0.0.1:1025]. Must be one of "-bs" or "-t" but can include additional flags.

Expected behavior
It should send an email.

Screenshots
If applicable, add screenshots to help explain your problem.

Version and configuration information (please complete the following information):

  • Host computer OS and Version: macOS High Sierra
  • Docker version information (use docker version) and insert it here.
Client:
 Version:      18.03.1-ce
 API version:  1.37
 Go version:   go1.9.5
 Git commit:   9ee9f40
 Built:        Thu Apr 26 07:13:02 2018
 OS/Arch:      darwin/amd64
 Experimental: false
 Orchestrator: swarm

Server:
 Engine:
  Version:      18.03.1-ce
  API version:  1.37 (minimum version 1.12)
  Go version:   go1.9.5
  Git commit:   9ee9f40
  Built:        Thu Apr 26 07:22:38 2018
  OS/Arch:      linux/amd64
  Experimental: true
  • ddev version information (use ddev version)
commit	v0.19.0                         
domain	ddev.local                      
cli   	v0.19.0                         
web   	drud/nginx-php-fpm-local:v0.19.0
db    	drud/mariadb-local:v0.19.0      
dba   	drud/phpmyadmin:v0.19.0         
router	drud/ddev-router:v0.19.0
  • config.yaml contents for the misbehaving project
APIVersion: v0.19.0
name: typo3-9
type: typo3
docroot: public
php_version: "7.2"
router_http_port: "80"
router_https_port: "443"
xdebug_enabled: false
additional_hostnames: []
provider: default
  • Do you have any custom configuration (nginx, php, mysql) in the .ddev folder? If so, have you tried without them?
@rickmanelius
Copy link
Contributor

rickmanelius commented Jun 15, 2018

Assigning over to @andrewfrench to help verify the pre/post behavior. Two things jumped out to me. One is that logging into a webhead and running mailhog sendmail -h shows this -t flag as mostly ignored ("Ignored. This flag exists for sendmail compatibility. (default true)"). The second is I'm curious if despite this warning the email is still being sent to and viewable within mailhog at http://PROJECTNAME.ddev.local:8025 as mentioned in ddev describe.

@andrewfrench
Copy link
Contributor

andrewfrench commented Jun 15, 2018

I can confirm the issue on a fresh install of TYPO3 v9.3.0 using ddev v0.19.0:

  • an error is returned from the Test Mail Setup tool after sending a test email
  • no sent mail is viewable from Mailhog

@rickmanelius
Copy link
Contributor

rickmanelius commented Jun 15, 2018

@andrewfrench. Excellent! With the applied change can we confirm capture and that it’s not sent externally? If so we are probably safe to pull. Thanks!

@andrewfrench
Copy link
Contributor

andrewfrench commented Jun 15, 2018

Yep, testing that now.

@rfay
Copy link
Member

rfay commented Jun 16, 2018

I don't believe this would have anything to do with TYPO3, all uses of mailhog should be broken given this situation.

@spoonerWeb
Copy link
Contributor Author

spoonerWeb commented Jun 16, 2018

I only can say that it works with parameter (and the mail was in MailHog), without it didn't work.

@rfay
Copy link
Member

rfay commented Jun 17, 2018

I just tested /usr/local/bin/mailhog sendmail test@example.org --smtp-addr 127.0.0.1:1025 both on the command line in the web container and using Drupal and it works fine, and it also fits with traditional usage of the sendmail binary (which does not require the -t flag). TYPO3 should be using php to send the email, so it shouldn't even be exposed to this command, so I'm a little confused how this works. Why would TYPO3 be parsing the command line? Or is TYPO3 somehow adding args or ...?

I suspect that TYPO3 is configured to use sendmail directly, rather than using PHP? We may be dealing with a TYPO3 bug here.

It's also reasonable to try using the mhsendmail utility suggested/provided with mailhog, https://github.com/mailhog/MailHog/blob/master/README.md

I'm not objecting to the strategy here, just trying to make sure we completely understand and fix the right thing. If there's a TYPO3 bug, let's fix that.

@michadu
Copy link
Contributor

michadu commented Jun 17, 2018

In my fresh installed TYPO3 v9 Installation I have to set this 2 settings in "Admin Tools" -> "Settings" -> "Configure Installation-Wide Options" to get the Testmail working:
[MAIL][transport] = smtp
[MAIL][transport_smtp_server] = localhost:1025

@rickmanelius rickmanelius added this to the v1.0.0 milestone Jun 25, 2018
@rfay
Copy link
Member

rfay commented Jun 28, 2018

Copied from #925 (comment)

Very thoughtful response from @jigal in slack:

I did some digging in mail handling in PHP and how we can use this in TYPO3.
TYPO3 uses SwiftMailer to send emails. SwiftMailer has deprecated the use of the PHP mail() function as mail transport and can remove support completely at any moment. Therefore we have to switch to either "sendmail" or "SMTP".
According to the PHP documentation mail() uses either sendmail (or something compatible) or SMTP (only on Windows and only if sendmail_path is empty). This is configured in the php.ini settings.
TYPO3 can use the php.ini settings (at least for new installations) to configure the mail settings as most installations have a working mail() function. If sendmail_path is empty (and SMTP is empty on Windows) we can only ask the user how installs TYPO3.
So, please don't rely on the 'mail' transport, but make sure the php.ini setting sendmail_path can be copied to the TYPO3 mail settings and SwiftMailer can use that command. If someone prefers to use SMTP they can configure this themselves IMO.

Edit: Links to follow up on this:

Swift_MailTransport deprecated
Stack Overflow discussion

@rfay rfay changed the title Missing parameter for sendmail command in TYPO3 configuration Mailhog doesn't work with TYPO3 ddev configuration Jul 3, 2018
@rfay rfay closed this as completed in 05111dc Jul 4, 2018
@dclear dclear removed the actionable label Jul 5, 2018
@DavidBruchmann
Copy link

DavidBruchmann commented Oct 4, 2022

I just had this issue with TYPO3 v12.
For some reason the config values from AdditionalConfiguration.php have been ignored.
After adding the values to LocalConfiguration.php everything worked fine.
The issue is not that the AdditionalConfiguration.php has been ignored (that might be another issue), but just to check if this hint might be relevant for some reason, i.e. that the file is in the wrong folder.

@rfay
Copy link
Member

rfay commented Oct 4, 2022

@DavidBruchmann it would be cool if you'd just do a quick install of generic TYPO3 quickstart and test. I think you'll find it works. https://ddev.readthedocs.io/en/latest/users/quickstart/#typo3

@DavidBruchmann
Copy link

DavidBruchmann commented Oct 4, 2022

@rfay It was a single case and never ever had problems with it, so in general I can confirm that by default it's working.

@ecosmox36
Copy link

ecosmox36 commented Oct 14, 2022

TYPO3 12 and Mailproblem Workaround

I got this problem with a fresh DDEV Container and TYPO3 12 at trying to send a testmail:

Error message: Connection could not be established with host "ssl://localhost:1025": stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages: error:1408F10B:SSL routines:ssl3_get_record:wrong version number

Setting this configuration to "false" and the testmail should work now:

[MAIL][transport_smtp_encrypt] = false

Somthing to Explain about these option:

Connect to the server using SSL/TLS (disables STARTTLS which is used by default if supported by the server). Must not be enabled when connecting to port 587, as servers will use STARTTLS (inner encryption) via SMTP instead of SMTPS. It will automatically be enabled if port is 465.

This is only for your local development required and should be never used at production systems!

@rfay
Copy link
Member

rfay commented Oct 14, 2022

The default configuration already has that, and has for some time, probably years, see https://github.com/drud/ddev/blob/master/pkg/ddevapp/typo3/AdditionalConfiguration.php#L34

You must not be using the typo3 project type or have setings_management_disabled: true ?

If you think there's a problem with how this is working please open a new issue, but it looks to me like the traditional config is exactly correct?

@ecosmox36
Copy link

ecosmox36 commented Oct 14, 2022

Thanks for reply then i guess this is the same Problem like David with the AdditionalConfiguration and i have to dive deeper here 😸

@DavidBruchmann
Copy link

DavidBruchmann commented Oct 14, 2022

@ecosmox36 just for the case that you use already TYPO3 v12: https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Breaking-98319-NewFileLocationForLocalConfigurationphpAndAdditionalConfigurationphp.html

@ecosmox36
Copy link

ecosmox36 commented Oct 14, 2022

@DavidBruchmann talking about the Topic in the typo3 slack channel, now i know the config files have moved and renamed, reading the doc some Minutes before 😄

And my DDEV Container was 1.21.1 but there was a Release 3 days Ago with TYPO3 v12 Support

So i will try it with the latest release again

Thanks and many thanks to @rfay also for this great solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants