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

[5.2] Sending to a Specified Address (Global "to") #8894

Closed
wants to merge 5 commits into from
Closed

[5.2] Sending to a Specified Address (Global "to") #8894

wants to merge 5 commits into from

Conversation

@clemblanco
Copy link
Contributor

@clemblanco clemblanco commented May 26, 2015

Sometimes you want to avoid email real customers. The two solutions given by Laravel as per as the official documentation are:

  • Using "pretend" to log the emails into the log file.
  • Using something like http://mailtrap.io.

Like with Symfony2, here we also give the ability to the developer to specify one email address which will receive every single email from his application. Could be very useful on a staging environment where you don't want to email real customers and where the actual tester wouldn't have access to the log files or wouldn't be able to use mailtrap.

@taylorotwell
Copy link
Member

@taylorotwell taylorotwell commented May 26, 2015

Wouldn't using a ->to() method call in your Mail::send override or at least append to this?

@GrahamCampbell GrahamCampbell changed the title Sending to a Specified Address (Global "to") [5.1] Sending to a Specified Address (Global "to") May 26, 2015
@clemblanco
Copy link
Contributor Author

@clemblanco clemblanco commented May 26, 2015

I don't want to append, I would like to override.
I don't want to change my codebase for that, I would like this to be set at the environment level.
Just realized that this is not complete... Gimme a sec...

@clemblanco
Copy link
Contributor Author

@clemblanco clemblanco commented May 26, 2015

Ok this has been tested and it works as I expected. If I setup the 'to' array in any mail.php config file for a specific environment, all emails are sent to this address.

* Set the global to address and name.
*
* @param string $address
* @param string $name

This comment has been minimized.

@GrahamCampbell

GrahamCampbell May 26, 2015
Member

The needs changing to string|null. string is wrong.

This comment has been minimized.

@clemblanco

clemblanco May 26, 2015
Author Contributor

Well, was already wrong initially on the alwaysFrom() function then as I got it from there. Will do that on both.

This comment has been minimized.

@GrahamCampbell

GrahamCampbell May 26, 2015
Member

Both are wrong then, yeh.

This comment has been minimized.

@lukasgeiter

lukasgeiter May 26, 2015
Contributor

@GrahamCampbell Parameters that default to null are documented like that in many places in the framework. Just one example: Query Builder

@GrahamCampbell
Copy link
Member

@GrahamCampbell GrahamCampbell commented May 26, 2015

Please fix the merge conflicts.

@clemblanco
Copy link
Contributor Author

@clemblanco clemblanco commented May 26, 2015

Yep my bad I forked this ages ago. Was in 4.2. I need to get my fork up to date first. Will do it later...

@clemblanco
Copy link
Contributor Author

@clemblanco clemblanco commented May 28, 2015

Should be alright now. Let me know if there is any issue.

@@ -103,8 +103,8 @@ public function __construct(Factory $views, Swift_Mailer $swift, Dispatcher $eve
/**
* Set the global from address and name.
*
* @param string $address
* @param string $name
* @param string $address

This comment has been minimized.

@GrahamCampbell

GrahamCampbell May 28, 2015
Member

Don't align this please - just use 2 spaces.

@@ -113,6 +113,18 @@ public function alwaysFrom($address, $name = null)
}

/**
* Set the global to address and name.
*
* @param string $address

This comment has been minimized.

@GrahamCampbell

GrahamCampbell May 28, 2015
Member

Same here.

@@ -68,11 +68,16 @@ public function returnPath($address)
* Add a recipient to the message.
*
* @param string|array $address
* @param string $name
* @param string|null $name
* @param boolean $override Will force ignoring the previous recipients

This comment has been minimized.

@GrahamCampbell

GrahamCampbell May 28, 2015
Member

bool not boolean, and don't align it please.

This comment has been minimized.

@GrahamCampbell

GrahamCampbell May 28, 2015
Member

Also, could you move this argument description to be the "Long description" please.

This comment has been minimized.

@clemblanco

clemblanco May 28, 2015
Author Contributor

@GrahamCampbell What do you mean? What do you call the "Long description"? The function's description? For instance "Add a recipient to the message."?

{
if ($override) {

This comment has been minimized.

@GrahamCampbell

GrahamCampbell May 28, 2015
Member

brace on a newline plz

@GrahamCampbell GrahamCampbell changed the title [5.1] Sending to a Specified Address (Global "to") [5.2] Sending to a Specified Address (Global "to") Jun 1, 2015
GrahamCampbell pushed a commit that referenced this pull request Jun 2, 2015
@GrahamCampbell
Copy link
Member

@GrahamCampbell GrahamCampbell commented Jun 2, 2015

Thank you @Claymm. We've applied this to 5.1.

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

Successfully merging this pull request may close these issues.

None yet

4 participants