Skip to content
Advertisement

Submit Contact Responses To email

I am using repl.it to build my website, however, repl.it has a server named HTML/CSS/JS and it does not support PHP which is mainly used to submit contact responses to email. The website is built in the HTML/CSS/JS Server. So I cannot use PHP to submit contact responses to email. Is there an alternate way of doing it with Node.js?

I still have the PHP set up but it just needs to be converted to Node.js if that is possible.

PHP File:

JavaScript

REST OF The CODE:

JavaScript
JavaScript

Is there a way to translate the PHP code into Javascript, and whenever the user hits the submit button, the responses get sent to email?

Advertisement

Answer

Generally speaking, although repl.it has done a lot of progress since it has been online, like featuring hosting your repl as well as theirs unique upm (repl.it universal package manager), I’d suggest that it isn’t, at least yet, a suitable platform to build such an app despite being inherently simple. repl.it is a very restricted platform and for good security-wise reasons.

With that being said, in case you insist on building this app in their environment while assuming you don’t have any node.js background, instead of creating an HTML,CSS,JS repl, you could create a PHP Web Server one and upload all the website’s static files in the local folder under the repl’s Files section.

Now, as mentioned before, because repl.it is a very restricted environment you’d probably notice that it doesn’t support the PHP’s mail function, nor curl. As a workaround, you can use an email sending API like SendGrid’s (btw they offer a free tier plan, allowing you to send 100 emails/day) and implement it using the file_get_contents function, which, apparently, repl.it does fully support.

An example would be something as follows:

index.html

JavaScript

style.css

JavaScript

scripts.js

JavaScript

index.php

JavaScript

send-mail.php

JavaScript

This example is only a demonstration for you to get an idea regarding how to do so. Just bear in mind that it doesn’t apply any security best practices whatsoever!

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement