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

It's not possible to set an email recipient's name when using a Notification sent via the Mail channel #25238

Closed
JackWH opened this issue Aug 16, 2018 · 4 comments

Comments

@JackWH
Copy link
Contributor

JackWH commented Aug 16, 2018

This affects Laravel 5.6.

When sending email, it's best practice to set the recipient name alongside their email address — e.g. John Smith <john.smith@example.com>. This can help reduce the likelihood of emails going to spam.

When using a Illuminate\Mail\Mailable class, you can use the to() function to set the name and address:

/**
 * Set the recipients of the message.
 *
 * @param  object|array|string  $address
 * @param  string|null  $name
 * @return $this
 */
public function to($address, $name = null)
{
    return $this->setAddress($address, $name, 'to');
}

Likewise, you can also do this with the Mail facade:

Mail::to([['name' => 'John Smith', 'email'=> 'john.smith@example.com']])->send(
    (new MyMailable($content))
);

However, the Laravel docs suggest using an Illuminate\Notifications\Messages\MailMessage class to issue notifications. This class doesn't have any kind of to() method defined on it.

It will automatically detect the recipient's email when you call it against a User class, but will simply send to john.smith@example.com as opposed to John Smith <john.smith@example.com>.

The latter option would increase deliverability and reduce the likelihood of emails disappearing into spam.

@shrft
Copy link
Contributor

shrft commented Aug 19, 2018

I can make changes and send pull request if nobody working on it yet.

@JackWH
Copy link
Contributor Author

JackWH commented Aug 20, 2018

@shrft Thanks, I haven't done anything on this yet myself so a pull request would be much appreciated.

@shrft
Copy link
Contributor

shrft commented Aug 26, 2018

hi. it seems this is already fixed a while ago.
#24606

@laurencei
Copy link
Contributor

Hi there,

Welcome to Laravel and we are glad to have you as part of the community.

Unfortunately this GitHub area is not for ideas, suggestions etc. This is only for issues/bugs with the framework code itself.

I will be closing your ticket here. You are able to open a ticket at https://github.com/laravel/ideas

Alternatively you are able to open a PR using the Contributions guidelines: https://laravel.com/docs/5.7/contributions#which-branch

If you feel I've closed this issue in error, please provide more information about how this is a framework issue, and I'll reopen the ticket.

Thanks in advance.

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

3 participants