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

xXSamXx's avatar

(SMTP) local.ERROR : Expected response code 250 but got code "550", with message "550 5.1.0 invalid domain

I am trying to configure the SMTP mail on my hosting server with a laravel 8 project, I entered the data on the .env file but when I try to send the form I get a server error 500, from the log file I found that the error in detail is this here: local.ERROR : Expected response code 250 but got code "550", with message "550 5.1.0 invalid domain. I tried the SMTP data also on the local machine and the form works while on the hosting server it does not, I also tried to launch commands from the web.php with Artisan following the routes, the following:

Route :: get ('cache', function () {
     \ Illuminate \ Support \ Facades \ Artisan :: call ('config: cache');
     echo 'ok';
});
Route :: get ('clear', function () {
     \ Illuminate \ Support \ Facades \ Artisan :: call ('config: clear');
     echo 'ok';
});

but even in this case the error continues to persist and at this point I don't know where to put my hands. Hope someone can help me and thanks in advance

0 likes
30 replies
sr57's avatar

@xxsamxx

Welcome to Laracast

First, to make your post readable, put your code between 3`

like this

For your pb, did you define a (or the right) MX record in your DNS?

xXSamXx's avatar

@sr57 Thanks for your welcome and advice, I have updated the question. By pd do you mean the database? If yes, however, I don't think I have set any MX records

xXSamXx's avatar

@iftekhs oh right, sorry but i'm not native english speaker so sometimes i don't understand some abbreviations, however the answer remains the same i don't think i have set any mx records.

1 like
iftekhs's avatar
iftekhs
Best Answer
Level 13

Well how I usually do it is like this ->

MAIL_MAILER=mail
MAIL_HOST=mail.domain.com
MAIL_PORT={your mail port}
MAIL_USERNAME={yourn mail username}
MAIL_PASSWORD={your mail password}
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"

and inside config/mail.php i used ->

<?php

return [

    'driver' => env('MAIL_DRIVER', 'mail'),
    'host' => env('MAIL_HOST', 'mail.host.com'),
    'port' => env('MAIL_PORT', 465),
    'from' => [
        'address' => '[email protected]',
        'name' => 'host.com',
    ],
    'encryption' => env('MAIL_ENCRYPTION', 'tls'),
    'username' => env('MAIL_USERNAME'),
    'password' => env('MAIL_PASSWORD'),

    // 'mailers' => [
    //     'smtp' => [
    //         'transport' => 'smtp',
    //         'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
    //         'port' => env('MAIL_PORT', 587),
    //         'encryption' => env('MAIL_ENCRYPTION', 'tls'),
    //         'username' => env('MAIL_USERNAME'),
    //         'password' => env('MAIL_PASSWORD'),
    //         'timeout' => null,
    //         'auth_mode' => null,
    //     ],

    //     'ses' => [
    //         'transport' => 'ses',
    //     ],

    //     'mailgun' => [
    //         'transport' => 'mailgun',
    //     ],

    //     'postmark' => [
    //         'transport' => 'postmark',
    //     ],

    //     'sendmail' => [
    //         'transport' => 'sendmail',
    //         'path' => '/usr/sbin/sendmail -bs',
    //     ],

    //     'log' => [
    //         'transport' => 'log',
    //         'channel' => env('MAIL_LOG_CHANNEL'),
    //     ],

    //     'array' => [
    //         'transport' => 'array',
    //     ],
    // ],

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

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

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

];

xXSamXx's avatar

@iftekhs ok, so as default values in the mail.php I have to put the same ones that I put in the .env file? For example as MAIL_ENCRYPTION I have ssl, consequently in the mail.php as default I insert ssl?

xXSamXx's avatar

@iftekhs Meanwhile, I have already tried to do as you advised by modifying the mail.php file and doing a

config: cache

and a

config: clear

again for safety, but the error continues to persist, this is what I entered in the mail file .php:

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Default Mailer
    |--------------------------------------------------------------------------
    |
    | This option controls the default mailer that is used to send any email
    | messages sent by your application. Alternative mailers may be setup
    | and used as needed; however, this mailer will be used by default.
    |
    */

    'default' => env('MAIL_MAILER', 'smtp'),

    /*
    |--------------------------------------------------------------------------
    | Mailer Configurations
    |--------------------------------------------------------------------------
    |
    | Here you may configure all of the mailers used by your application plus
    | their respective settings. Several examples have been configured for
    | you and you are free to add your own as your application requires.
    |
    | Laravel supports a variety of mail "transport" drivers to be used while
    | sending an e-mail. You will specify which one you are using for your
    | mailers below. You are free to add additional mailers as required.
    |
    | Supported: "smtp", "sendmail", "mailgun", "ses",
    |            "postmark", "log", "array"
    |
    */

    'driver' => env('MAIL_DRIVER', 'mail'),
    'host' => env('MAIL_HOST', 'smtps.aruba.it'),
    'port' => env('MAIL_PORT', 465),
    'from' => [
        'address' => '[email protected]',
        'name' => env('MAIL_FROM_NAME'),
    ],
    'encryption' => env('MAIL_ENCRYPTION', 'ssl'),
    'username' => env('MAIL_USERNAME'),
    'password' => env('MAIL_PASSWORD'),

    /*
    |--------------------------------------------------------------------------
    | 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', 'Example'),
    ],

    /*
    |--------------------------------------------------------------------------
    | 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'),
        ],
    ],

];

and this is my .env file:

MAIL_MAILER=smtp
MAIL_HOST=smtps.aruba.it
MAIL_PORT=465
MAIL_USERNAME={my_username}
MAIL_PASSWORD={my_password}
MAIL_ENCRYPTION=ssl
[email protected]
MAIL_FROM_NAME="${APP_NAME}"
iftekhs's avatar

@xXSamXx in your server you need to change smtp to mail like this->

MAIL_MAILER=mail
MAIL_HOST=mail.aruba.it
MAIL_PORT=465
MAIL_USERNAME={my_username}
MAIL_PASSWORD={my_password}
MAIL_ENCRYPTION=ssl
[email protected]
MAIL_FROM_NAME="${APP_NAME}"

And I also suggest copying the content of my mail.php file and replacing it with yours.

xXSamXx's avatar

@iftekhs Still nothing, as always before trying again I cleared the cache and also the clear command

iftekhs's avatar

@xXSamXx Are you using managed hosting? then I would suggest you contact their support.

xXSamXx's avatar

@iftekhs I have already contacted them in reality, and they provided me with the SMTP data but nothing else, they told me to turn to an expert in case but it doesn't make much sense

xXSamXx's avatar

@iftekhs Yes, I've already looked I believe every single article where they mention this error and tried all the solutions but nothing

xXSamXx's avatar

@iftekhs I have an update: I tried to double check the log file to be sure and there is no more old error now it is here:

local.ERROR: proc_open () has been disabled for security reasons
sr57's avatar

@xxsamxx

did you define a (or the right) MX record in your DNS?

does not refer to laravel code, but your DNS settings, have you checked this point?

xXSamXx's avatar

@sr57 i checked and for now i have DNS management turned off so i didn't touch anything in case i can turn it on

sr57's avatar

@xXSamXx

Do this command return your mail server (the one you code in .env)?

dig MX your_domain
xXSamXx's avatar

@sr57 Sorry but I don't know this command, what should I do to answer your question

xXSamXx's avatar

@sr57 i actually work on windows, how can i still use this command?

xXSamXx's avatar

@sr57 I have heard about it but I would prefer to get involved by following a tutorial or something similar, by chance you already know something? Otherwise I try even alone it is not a problem

xXSamXx's avatar

@sr57 Ok I have installed dig and launched the command what should I check, in case I can share the entire response of the command or there is some sensitive data?

sr57's avatar

@xXSamXx

See my previous answer

Do this command return your mail server (the one you code in .env)?

That's said there is no sensitive data, just replace your domain by xxxxx if you don't want to share it here.

sr57's avatar

Must leave, hope this helped you.

If you get the right mail server with this command it's another pb, if not you have to setup it first.

xXSamXx's avatar

@sr57 here it is:

; <<>> DiG 9.16.29 <<>> MX mydomain.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 63827
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;mydomain.com.             IN      MX

;; ANSWER SECTION:
mydomain.com.      21600   IN      MX      10 mx.mydomain.com.

;; Query time: 94 msec
;; SERVER: 192.168.8.1#53(192.168.8.1)
;; WHEN: Sun May 29 00:42:09 ora legale Europa occidentale 2022
;; MSG SIZE  rcvd: 65
sr57's avatar

@xxsamxx

in .env youn should have

MAIL_HOST= mx.mydomain.com

or, having a look to your previous answer)

MAIL_HOST=mailfree.aruba.it

dig mx aruba.it

; <<>> DiG 9.16.1-Ubuntu <<>> mx aruba.it
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 16377
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;aruba.it.			IN	MX

;; ANSWER SECTION:
aruba.it.		600	IN	MX	10 mailfree.aruba.it.
xXSamXx's avatar

@sr57 I always have this error in the log file

Local.error: proc_open () Has Been Disabled for Security Reasons

also by changing the .env file

Please or to participate in this conversation.