Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel how to configure sender name instead of email address

Tags:

php

email

laravel

How do I configure the sender name in the .env or mail.php files in Laravel? I set the email configuration in both of these files as below.

.env:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=jayabahadurgmail.com
MAIL_PASSWORD=9491A$$R
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS = [email protected]
MAIL_FROM_NAME = NO-REPLY

config/mail.php file:

'from' => [
    'address' => '[email protected]',
    'name' => 'NONAME'
],

The issue is that when I receive an email, it shows my email address like "jayabahadurgmail.com", but I want to show "NO-REPLY" instead of my email.

like image 201
Muhammad Kazim Avatar asked Nov 18 '25 17:11

Muhammad Kazim


1 Answers

Gmail automatically rewrites the "from" header of any messages sent through its SMTP server to the default "Send mail as" email address assigned in the Gmail or Google Apps account used to authenticate (in this case, your personal account).

This SMTP service is intended for personal use only, so its not very flexible. We can change this address by modifying the default account in the Gmail settings, but this still won't enable us to configure the "from" address through the application.

In development, this behavior may not matter, but for production environments, we'd need to use a mail provider that respects the headers sent from the application. Gmail also limits the rate of emails sent through its SMTP server in this way, which prevents us from using the service for most applications in production that send any significant amount of email.

like image 51
Cy Rossignol Avatar answered Nov 21 '25 06:11

Cy Rossignol



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!