-
-
Notifications
You must be signed in to change notification settings - Fork 585
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
Automate Laravel MailHog capture configuration #4822
Automate Laravel MailHog capture configuration #4822
Conversation
Download the artifacts for this pull request: |
@@ -56,6 +56,7 @@ func laravelPostStartAction(app *DdevApp) error { | |||
"DB_USERNAME": "db", | |||
"DB_PASSWORD": "db", | |||
"DB_CONNECTION": dbConnection, | |||
"MAIL_HOST": "127.0.0.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't it need the port as well, 1025?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The port is set to 1025
by default.
Composer copies over the .env.example
which has the following mail related settings:
MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"
You can see that the default mail host doesn't work OOTB.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update PR to include port if you would prefer it in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1025 is an unusual default mail port (25 is normal). Oh, I see, it's already there MAIL_PORT=1025
. But we didn't have MAIL_HOST
set right. Thanks.
It doesn't look like the "send email" instructions are adequate for a novice like me to manually test. Can you add more detail about how to do it? Thanks! |
I updated the description to try and make it simpler. As long as you have a working Laravel install, you should be able to enter "tinker mode" (REPL). REPL allows you to run PHP commands in a bootstraped environment. The command in the description tries to send an email; it it should be a simple copy/paste. Let me know if you are getting a specific error message. |
I have a |
Yes, |
That also means the quickstart could use it instead of |
Thanks for tinker mode! Let me know when this is ready for review. |
d649d53
to
84d8fda
Compare
Sorry I haven't tested yet, will get to it! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works perfectly, code is good, thanks so much. thanks for the good testing instructions.
The Issue
Laravel requires additional configuration to work with DDEV's Mailhog.
With current setup, sending an email results in the following exception:
How This PR Solves The Issue
This PR add
MAIL_HOST=127.0.0.1
to the project's.env
.Manual Testing Instructions
Follow quickstart guide for a Laravel project. You should see the Laravel "Welcome page"
Launch Mailhog to watch for email:
Enter "tinker mode" by typing the following command:
Copy and past (or type) the following command into "tinker mode". This will attempt to send an email which should be caught by Mailhog.:
Type
exit
to exit "tinker mode".Note: if you make changes to
.env
(or any php file), you need to exit and re-enter "tinker mode" for changes to apply.Related Issue Link(s)
Fixes #4821
Release/Deployment Notes
Recent versions of DDEV automate the database settings, so it seems consistent to include the mail server.
Developers are free to opt out of DDEV managing this using currently documented best practises.