hey guys configuring the mail service that comes with laravel.
here's my mail.php file
/*
|--------------------------------------------------------------------------
| Global "From" Address
|--------------------------------------------------------------------------
|
| You may wish for all e-mails sent by your application to be sent from
| the same address. Here, you may specify a name and address that is
| used globally for all e-mails that are sent by your application.
|
*/
'from' => ['address' => 'someguy@somehost.com', 'name' => 'Some Guy Senderl'],
here's my .env file
APP_ENV=local
APP_DEBUG=true
APP_KEY=secret
DB_HOST=localhost
DB_DATABASE=c9
DB_USERNAME=secret
DB_PASSWORD=
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=localhost
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=secret@gmail.com
MAIL_PASSWORD=secret
MAIL_ENCRYPTION=tls
and here's my route
Route::get('/email', function() {
Mail::send('emails.welcome', ['name' => 'bvc'], function ($message) {
$address = 'support@secret.com';
$message->to('secret@gmail.com');
$message->from($address, 'Thank you');
$message->subject('thanks for signing up, all you need to do is confirm your email address and we are good to go');
});
My question is this.
Whenever i send an email the sender is still secret@gmail.com
so basically im sending stuff to myself from myself rather than the $message->from($address, 'Thank you');
so im confused on why that is happening. I do have the global from address
filled but that seems to be getting overridden as well.
This isn't a Laravel issue, it is an SMTP issue. Most SMTP hosts (like gmail) do not let you change the "from" address, or only let you change it to an address that is linked to your account and verified that you own it. This is done to reduce spam, as you shouldn't be able to send an email and make it look like it came from anyone.
If you'd like to be able to send mail as support@secret.com
, you will need to link that email to your secret@gmail.com
account. In gmail, go to Settings
, go to Accounts and Import
, and then under Send mail as
, click the Add another email address you own
. Once you finish the process to link support@secret.com
to your gmail account, you should be able to change the from address to it.