1

I have recently started working on a Laravel site, having never previously used Laravel before, and only having used PHP very briefly, about 9/10 years ago.

There is a form on one of the web pages, which displays information regarding transactions due to be made by various companies through our client's website. The form displays information such as name, ID, value of the transaction, contact email address, etc, and is used to send the companies reminders to pay those amounts.

All of the entries in the 'contact email address' column display a small pencil icon next to them, to allow the administrator to change the email address that the reminder will be sent to. When they click the pencil icon, a dialog box is opened showing the contact whose email address is currently set to receive the email, and giving the user the option to add a new contact to send the email to by filling out a small form.

The form contains fields for surname, forename & email address, and has a button to 'Add Contact'.

At the moment, when a user fills this form in, and clicks the 'Add Contact' button, an error message is displayed on the web page saying:

An error has occurred adding your contact. If the problem persists please contact us.

In the browser console, the Network tab shows an exceptionMessage that says:

Connection could not be established with host mailtrap.io [Connection timed out #110] - /home/vagrant/.../StreamBuffer.php - 272

I came across this question on SO, about 'Connection timed out #110' error with Laravel on Localhost, and tried doing what the most upvoted answersuggested by changing my MAIL_HOST from mailtrap.io to smtp.mailtrap.io, but this didn't seem to make a difference.

I also tried to see what value the MAIL_HOST variable holds by adding a dd into the method, as suggested in the accepted answer:

...
dd(env('MAIL_HOST'));
error => {
    ...

but I can't actually see that debug displayed in the console at all... it just shows:

Get http://mysite.test/.... 404 (Not Found)

Refused to execute script from provisional-reminders:1 'http://mysite.test/...' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

...

Cross-Origin Read Blocking (CORB) blocked cross-origin response http://... with MIME type text/html.

Failed to load http://... provisional-reminders:1...: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://mysite.test' is therefore not allowed access.

Error syncing with Cold Fusion Server error

GET http://mysite.test/... 404 (Not Found)

POST http://mysite.test/... 400 (Bad Request)

Error: [object Object]

POST http://mysite.test/... 400 (Bad Request)

Error: [object Object]

Anyone have any ideas why I'm getting this Connection could not be established with host mailtrap.io [Connection timed out #10] error?

Noble-Surfer
  • 3,052
  • 11
  • 73
  • 118
  • 1
    Actually the connection error should come because of your host `mailtrap.io` not being `smtp.mailtrap.io`. Where have you changed your MAIL_HOST? Your `dd` is PHP / Laravel code, you can't add it in a TypeScript (.ts) file, you need to add it somewhere in your controller, before the view is rendered. – Matthias S Sep 12 '18 at 10:52
  • I changed the `MAIL_HOST` environment variable from `mailtrap.io` to `smtp.mailtrap.io` in .env.example in the root of my project, but when I refreshed my page, and tried again, I got the same error- would I need to restart any services or anything before this change will make I difference? – Noble-Surfer Sep 12 '18 at 11:00
  • 1
    @someone2088 Changed `MAIL_HOST` in `.env` file, not in `.env.example`. – Saumini Navaratnam Sep 12 '18 at 11:02
  • Spot on- that sorted it. If you want to post that as an answer, I'll mark it accepted. Thanks. – Noble-Surfer Sep 12 '18 at 11:09
  • 1
    I think the question has not much value to the public because you have a lot of content that is not really focusing on the issue. Therefore you might get users here via Google that look for something else (e.g. all the debugging code of you putting php code in typescript files). I would say either just delete the question or edit it to remove all the parts that are not about mailtrap.io and the error message and then accept the answer by @SauminiNavaratnam (if there will be one) – Matthias S Sep 12 '18 at 13:54
  • Edited to remove the unnecessary code. – Noble-Surfer Sep 13 '18 at 09:48

0 Answers0