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

Update mail.md #10151

Merged
merged 2 commits into from
Feb 6, 2025
Merged

Update mail.md #10151

merged 2 commits into from
Feb 6, 2025

Conversation

akoper
Copy link
Contributor

@akoper akoper commented Feb 5, 2025

To send email with Mailgun (and any external mail service, probably) and Laravel, there are three changes to config files that have to be made. Two of them had code examples in the documentation. The third one did not. Currently, it is just written with words as "change the default value..." but the fact that the item in the array is named "default" and value in the key/value pair is "default" leads to ambiguity.

After reading Laraval mail's documentation, doing a lot of set up and configuring, and programming a controller and mailable, I experienced hours of stress and frustration because the emails weren't being sent. All of the Mailgun env and config vars seemed to be good. This was the problem.

Please accept this mail documentation change. The one-line code example is important in getting mail to work

To send email with Mailgun (and any external mail service, probably) and Laravel, there are three changes to config files that have to be made.  Two of them had code examples in the documentation.  The third one did not.  Currently, it is just written with words as "change the default value..." but the fact that the item in the array is named "default" and value in the key/value pair is "default" leads to ambiguity.

After reading Laraval mail's documentation, doing a lot of set up and configuring, and programming a controller and mailable, I experienced hours of stress and frustration because the emails weren't being sent.  All of the Mailgun env and config vars seemed to be good.  This was the problem.

Please accept this mail documentation change.  The one-line code example is important in getting mail to work
mail.md Outdated Show resolved Hide resolved
mail.md Outdated Show resolved Hide resolved
mail.md Outdated Show resolved Hide resolved
mail.md Outdated Show resolved Hide resolved
@taylorotwell
Copy link
Member

Can you elaborate more on which part confused you?

@akoper
Copy link
Contributor Author

akoper commented Feb 5, 2025

@taylorotwell I want my application to send email. I started implementing a mail feature with Mailgun last night. Generally, I think it started with the mail documentation page being 45 screens long. This sends the message that mail is really complicated and there is a lot to know (even knowing from experience there is some advanced stuff at the end of the documentation I surely wouldn't have to know).

Specifically, as I wrote in the comment in my PR, several changes have to be made to two config files (mail and services) when you implement email. Most of them have code examples in the documentation. Programming is very detail oriented. The smallest mistake can keep a program from running. The one change to config/mail.php that did not have a code example is the one that kept my code from working and the email being sent. This is why we show code snippets. This caused me hours of stress, frustration, anger and sadness trying to figure out why my implement-email-in-Laravel-with-Mailgun feature wasn't working.

The problem - besides my obvious inexperience - was that part of configuring config/mail.php was was written in English with no code sample and there were two 'defaults." I "set the default option in your application's config/mail.php configuration file to mailgun".

I changed the default

'default' => env('MAIL_MAILER', 'log'),

to this

'default' => env('mailgun', 'log'),

After hours of banging my head against the wall and fuzzy-logic problem solving, I happened to move my cursor over 'log' in my Jetbrains IDE and a tooltip appeared that said the word 'default' That's when I saw that that value in that key/value pair was a default. That was a part of what helped me solve my problem.

I certainly know the pattern of getting a constant's value from the env file. I think the fact that that wasn't simply assigned to a variable played a role in me messing this up.

Another thing about implementing email in Laravel with Mailgun that is somewhat confusing, a bit stressful and can lead to your code not working is that the variables that Mailgun produces don't match up with Laravel's Mailgun documentation. I educated guessed that Mailgun's "sending API key" was probably what Laravel called "MAILGUN_SECRET" But generally, not assigning the right/exact value to the right/exact variable in coding breaks your application.

Didn't expect my response to this PR's comments about changing a sentence the documentation to be this long, but maybe this has to do with the detail-oriented nature of programming, and helping Laravel and PHP get widely adopted.

@taylorotwell taylorotwell merged commit 4892dd2 into laravel:11.x Feb 6, 2025
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

Successfully merging this pull request may close these issues.

3 participants