Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Alewa's avatar
Level 2

Cannot send message without a sender address (Laravel 6)

I am having this email error message, Cannot send message without a sender address in my laravel 6 project and my website is online with godaady and my email is also setup in godaddy.

My mail.php file

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Mail Driver
    |--------------------------------------------------------------------------
    |
    | Laravel supports both SMTP and PHP's "mail" function as drivers for the
    | sending of e-mail. You may specify which one you're using throughout
    | your application here. By default, Laravel is setup for SMTP mail.
    |
    | Supported: "smtp", "sendmail", "mailgun", "mandrill", "ses",
    |            "sparkpost", "log", "array"
    |
    */

    'driver' => 'sendmail',

    /*
    |--------------------------------------------------------------------------
    | SMTP Host Address
    |--------------------------------------------------------------------------
    |
    | Here you may provide the host address of the SMTP server used by your
    | applications. A default option is provided that is compatible with
    | the Mailgun mail service which will provide reliable deliveries.
    |
    */

    'host' => 'smtp.gmail.com',

    /*
    |--------------------------------------------------------------------------
    | SMTP Host Port
    |--------------------------------------------------------------------------
    |
    | This is the SMTP port used by your application to deliver e-mails to
    | users of the application. Like the host we have set this value to
    | stay compatible with the Mailgun e-mail application by default.
    |
    */

    'port' => 587,

    /*
    |--------------------------------------------------------------------------
    | 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' => env('MAIL_FROM_ADDRESS', '[email protected]'),
        'name' => env('MAIL_FROM_NAME', 'GhanasShop Website'),
    ],

    /*
    |--------------------------------------------------------------------------
    | E-Mail Encryption Protocol
    |--------------------------------------------------------------------------
    |
    | Here you may specify the encryption protocol that should be used when
    | the application send e-mail messages. A sensible default using the
    | transport layer security protocol should provide great security.
    |
    */

    'encryption' => 'tls',

    /*
    |--------------------------------------------------------------------------
    | SMTP Server Username
    |--------------------------------------------------------------------------
    |
    | If your SMTP server requires a username for authentication, you should
    | set it here. This will get used to authenticate with your server on
    | connection. You may also set the "password" value below this one.
    |
    */

    'username' => '[email protected]',

    'password' => '**********',

    /*
    |--------------------------------------------------------------------------
    | Sendmail System Path
    |--------------------------------------------------------------------------
    |
    | When using the "sendmail" driver to send e-mails, we will need to know
    | the path to where Sendmail lives on this server. A default path has
    | been provided here, which will work well on most of your systems.
    |
    */

    'sendmail' => '/usr/sbin/sendmail -bs',

    /*
    |--------------------------------------------------------------------------
    | Markdown Mail Settings
    |--------------------------------------------------------------------------
    |
    | If you are using Markdown based email rendering, you may configure your
    | theme and component paths here, allowing you to customize the design
    | of the emails. Or, you may simply stick with the Laravel defaults!
    |
    */

    'markdown' => [
        'theme' => 'default',

        'paths' => [
            resource_path('views/vendor/mail'),
        ],
    ],

];

Can someone help?

0 likes
32 replies
Snapey's avatar

what do you have for mail in .env ? It will take priority over your values in mail.php

Alewa's avatar
Level 2

my .env file

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"
Snapey's avatar

put your From address details in there and run php artisan config:clear

Alewa's avatar
Level 2

i should put my form email address in the ,env file like this?

MAIL_DRIVER=smtp
[email protected]
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"

is it ok

Snapey's avatar

no

here

MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"
Alewa's avatar
Level 2

Thanks and should i leave the MAIL_HOST=smtp.mailtrap.io ?

Snapey's avatar

this mail config

'from' => [
        'address' => env('MAIL_FROM_ADDRESS', '[email protected]'),
        'name' => env('MAIL_FROM_NAME', 'GhanasShop Website'),
    ],

says get the values from the env file, and if they don't exist then use these as defaults

You should avoid putting implementation details in your code, pull them in from environment variables

Snapey's avatar

You have edited mail.php so it is not looking at the .env file

'host' => 'smtp.gmail.com',

You shoukd revert this for the same reasons mentioned earlier

1 like
Alewa's avatar
Level 2

I have change my .env to

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=********
MAIL_ENCRYPTION=tls
[email protected]
MAIL_FROM_NAME="${APP_NAME}"

The email is going from my laravel app but when i open my gmail, the email is not comming.

Alewa's avatar
Level 2

@snapey when i signup in with the first gmail everything works perfectly, but when i try to signup with different gmail accounts, my laravel app shows that everything is working but i am not recieving any messages in my other gmail accounts apart from the first gmail account i signup with which is working ok.

Snapey's avatar

check the MANY posts on this site with people having problems with gmail.

Also, check your sent folder. Gmail puts mail there if you send email to yourself.

Alewa's avatar
Level 2

There is nothing in the sent folder, and i am not sending email to myself. When you signup to my laravel app, it should automatically give you an account activation message in your email, but in this case only the first gmail account that i signup with is working but the other gmail accounts are not receiving activation message but my laravel app is also showing that user signup success and user should confirm their account in their email. Is it a cache problem?

Snapey's avatar

no, its not a cache problem. Have you checked the spam folder of those users?

Remember that your mail has a small chance of being delivered if you are saying that the mail is from [email protected] but actually you are using your own gmail address to send the email.

Google is not stupid. They know that if you send email with from as one address and it is coming from a different server then it must be spam

Alewa's avatar
Level 2

So please is there any way i can change email message from going to the spam folder?

Snapey's avatar

make sure you are sending FROM a valid address

If you are using gmail as your mail server then your mail must be from someone@gmail

Alewa's avatar
Level 2

i am using a valid address from my godaddy email address that i created which is [email protected]. And the website is also online, so you can try visiting www.ghanasshop.com

Please or to participate in this conversation.