You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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 theto()
function to set the name and address:Likewise, you can also do this with the
Mail
facade:However, the Laravel docs suggest using an
Illuminate\Notifications\Messages\MailMessage
class to issue notifications. This class doesn't have any kind ofto()
method defined on it.It will automatically detect the recipient's email when you call it against a
User
class, but will simply send tojohn.smith@example.com
as opposed toJohn Smith <john.smith@example.com>
.The latter option would increase deliverability and reduce the likelihood of emails disappearing into spam.
The text was updated successfully, but these errors were encountered: