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

chilldsgn's avatar

Sending mail returns error mkdir(): Too many links

Hello, I am new to these forums and started using laravel not too long ago, so please bear with me if i ask a stupid question. I have been googling and talking to another php dev who uses Laravel extensively for help as well.

I have a form set up (which sends mails just fine locally), but whenever I submit the form on, it returns an error: mkdir(): Too many links

    private function prepareCache($nsKey)
    {
        $cacheDir = $this->path.'/'.$nsKey;
        if (!is_dir($cacheDir)) {
            if (!mkdir($cacheDir)) {
                throw new Swift_IoException('Failed to create cache directory '.$cacheDir);
            }
            $this->keys[$nsKey] = [];
        }
    }

I am not trying to upload anything, and it is on a shared hosting environment so I cannot do any SSH stuff or clear the server cache or anything. I know it's not ideal, but that's what I unfortunately have to work with and I have no way of getting a VPS or dedicated server at the moment. I tried changing file permissions as well and my core files live outside public_html. Nothing along the lines of 777 which is really a bad idea.

Is it some kind of server configuration that the host used by the company I work for has to change? I am not a server admin person and mostly do front end design/dev work but really trying to get to the bottom of this.

Thanks in advance!

0 likes
2 replies
DariusIII's avatar

Shared hosting is bad idea from start.

Anyway, most likely you don't have permissions on server to create the needed cache folder.

Out of pure curiosity, why do you use cache folder for emails? Laravel has good support for caching out of the box, it just needs to be configured for your use case.

Personally, i use redis queues to send emails.

chilldsgn's avatar

I know shared hosting is a bad idea, but sadly I do not have much of a choice at this point :(

It appears to be an issue with the hosting provider, I uploaded the project to a different shared host I have access to and it works fine, no caching problems, no errors, mails send and deliver as I expect them to. It's not supposed to use cache folder for emails, however it uses session and cookies for the form.

I do not know much about server configs, like I said, i am a lowly front end designer/dev, but willing to learn more.

Anyway, it's not a Laravel issue, it's a hosting problem so if anyone else runs into this (because I had a hard time getting info on this type of error on a Laravel app on google), it's most likely a hosting problem and you should avoid using shared hosting with Laravel apps, or get your hosting provider to help you out, because it's some kind of server configuration they need to do in case you don't have that level of access.

1 like

Please or to participate in this conversation.