Two queries (mail & ajax)

Hello! First, I want to thank the provider of this wonderful free hosting service. I am not able to find anyone else giving such rich features at no cost. With other services, you’ll find slow speeds, poor cpanel, horrible php support, ads/overlays or other ways to torture.

Coming to the queries regarding the tiny final year project that I am willing to run here.
I’ve developed a script which is working on local host (WampServer). A part of it dynamically fetches a file sitting net to the caller file. The code is something like this.

if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } else { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("chatTxt").innerHTML = this.responseText; } }; xmlhttp.open("GET","getchat.php?id="+str,true); xmlhttp.send();

Its working on localhost, but whenever I upload it here, I get error 403 in browser’s JS console.

"Failed to load resource: the server responded with a status of 403 ()

joinclass.php?classid=23:1 Failed to load https://infinityfree.net/errors/403: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://stutea.rf.gd’ is therefore not allowed access. The response had HTTP status code 403."

Over internet, people have fixed it by allowing security mods and changing header. Can we do it here?

Second, I am unable to get mail() to work, Just wanted a simple registration information + approval mail to be sent. I’ve read that there are some templates to be followed here. I am unable to find any. Can anyone share a working mail() example with this host?

Thanks!

Are you trying to build a live chat script by any chance? If so, you might be hitting a security system which blocks chat scripts, because live chat scripts are not allowed on InfinityFree (just like most other free hosting providers and many low cost hosting providers).

As for PHP mail, please see this article: https://infinityfree.net/support/php-mail

@Admin said:
Are you trying to build a live chat script by any chance? If so, you might be hitting a security system which blocks chat scripts, because live chat scripts are not allowed on InfinityFree (just like most other free hosting providers and many low cost hosting providers).

As for PHP mail, please see this article: https://infinityfree.net/support/php-mail

Yes, but a very basic one, not for public use. And one without ajax is working.

Yes, I’ve seen this page before making this post. It doesn’t tell what are the allowable templates of mail() function. I was not able to send a basic text mail of 3-4 lines using host’s own email address (even to self).

@SAbbasi said:

@Admin said:
Are you trying to build a live chat script by any chance? If so, you might be hitting a security system which blocks chat scripts, because live chat scripts are not allowed on InfinityFree (just like most other free hosting providers and many low cost hosting providers).

As for PHP mail, please see this article: https://infinityfree.net/support/php-mail

Yes, but a very basic one, not for public use. And one without ajax is working.

Yes, I’ve seen this page before making this post. It doesn’t tell what are the allowable templates of mail() function. I was not able to send a basic text mail of 3-4 lines using host’s own email address (even to self).

It’s mostly specific messages of known CMS, like email confirmations from WordPress for example. If you completed all other checklist items in the article, then it’s likely that your messages do not pass the filters. If so, you may want to use an external email provider instead. Here is a guide on how to send email with SMTP: https://infinityfree.net/support/how-to-send-email-with-gmail-smtp

The problem is infinitely free implement a not ajax usage for the service…

@BenyaminL said:
The problem is infinitely free implement a not ajax usage for the service…

Ajax itself should work fine, as long as you only use ajax with scripts on the same domain and don’t use it for a live chat script.