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

ollie_123's avatar

ErrorException fgets(): SSL: Connection reset by peer

Evening All

I'm just trying to setup mail for a new app on a live server and i keep running into the above error.

I've tried SSL port 465 & TLS port 587 using the SMTP mailer but regardless of what i chance i get the above error. Please can someone advise where i'm going wrong?

MAIL_MAILER=smtp
MAIL_HOST=mail.myappname.co.uk
MAIL_PORT=465
[email protected]
MAIL_PASSWORD=********************
MAIL_ENCRYPTION=ssl
MAIL_FROM_NAME="My App Name"
[email protected]

In-between changes i've tried config:clear & cache:clear but still no joy.

Thank you in advance.

0 likes
22 replies
Snapey's avatar

You have mail server running on your domain?

ollie_123's avatar

Hey @snapey

Not sure if thats a question or a statement? Could you please elaborate.

the mail.myappname is the outgoing mail server. I also tried the host domain but still no joy. I tried googling but there was very limited information and i've not come across this error before.

Snapey's avatar

I'm checking that you actually have a mail server available for you to use?

ollie_123's avatar

Hi @snapey yes, i do. I also have another laravel app on this server and it works with sending mail

Snapey's avatar

So you can duplicate the config from the other application?

siangboon's avatar

if you tried port 587 with encryption as null it shouldn't give your SSL error...

have you try telnet from the server??

if one site configuration work on one site but apply exactly configuration to another site not work, most likely mean there is something not right on the network policy or the receiving server may whitelist certain ip address...

ollie_123's avatar

@snapey, yep i copied the config from the other app to this app and got the same error.

@siangboon i havent tried telnet but changing the encryption to NULL gives me an error of Expected response code 250 but got code "530", with message "530 Relaying not allowed - local sender address unknown "

Sinnbeck's avatar

Are you running the mailserver yourself? If so, what sort of mailserver are you running ? Postfix? Any chance that you havent allowed the new server to send using the smtp server?

ollie_123's avatar

Hi @sinnbeck i hope you're well?

The mailserver in use is part of cPanel from UKHost4u.

Sinnbeck's avatar

Oh great. I assume that means that there is support then. Try contacting them and ask if you need to allow the new server somehow.

ollie_123's avatar

Hey @sinnbeck ok, thank you. I'll give them a call today. I just wanted to check it wasnt something i was doing wrong.

Thanks all.

siangboon's avatar

530 Relaying not allowed - local sender address unknown i think this is a big hint for you to troubleshoot further... it look like the given email account does not exist... double check the configuration is accurate or any typo error properly...

Snapey's avatar

That error means that your from address is not one that the server recognises

Sinnbeck's avatar

@mubeenali Dont dont highjack other peoples threads to ask for help for your own. If snapey has anything help to offer, I am sure he will post on you thread.

ollie_123's avatar

Thanks guys. I removed the MAIL_FROM_ADDRESS for testing but forgot to add it back in. Now added back in and i get the same error but without the "local sender unknown"

Expected response code 354 but got code "530", with message "530 Relaying not allowed"

Sinnbeck's avatar

One idea

Are you using an other laravel version? Check mail.php in config.

Is the driver like this? (check all env variables are correct)

'default' => env('MAIL_MAILER', 'smtp'),
ollie_123's avatar

Hey @sinnbeck, good call. My other app is running 7.0.8 and this app is running 7.14.1 however both .env files are the same on the mail settings :/

Sinnbeck's avatar

Ok so the mail.php files are exactly the same? (in the config directory)

ollie_123's avatar

They are now ;) but it still gives me the same error of:-

Expected response code 354 but got code "530", with message "530 Relaying not allowed"

I think i'm going to have to call the host. Unfortunately i didn't get a chance today.

GustavoBretas's avatar

Hi folks,

I went trough this issues (ErrorException fgets(): SSL: Connection reset by peer) this week, and after investigate a little deeper, I found out that the problem is related to the Rate Limit configured on the smtp server.

So, for who has access to the smtp server, choose a Rate Limit enough to comply with your demand, and for who doens't, may need to work around the rate limit setting a timer to hold the queue when reach the limit

best regards

Please or to participate in this conversation.