Hello, I want to make a mail verification system for my game that I developed with nvgt. How can I do this? Thanks in advance for those who will help me.
Hi,
Sending an email is not the responsibility of your game directly; instead, your game should communicate with your server via API and your server should take care of actually sending the email. Here's what that might look like (warning: not simple):
First, you need a mail server. You can use a mail provider, or host your own using a package like Mail In a Box (https://www.mailinabox.email).
Then, once you have SMTP credentials set up, you're going to have to create an API on your server that your game can hit in order to perform email verification. Basically, this should receive a JSON payload from the game via (https) post request (and authentication info in HTTP headers). Validate this. Rate limit it. And for god's sake don't send the email body over as a string from your game. Email reputation matters and is very hard to get back once lost.
Finally, your server should create an email verification token in your database and send that to the address included in the JSON from your game.
Then, your game could pole another API endpoint every few seconds or so to check if the user has clicked the link and validated the email.
As you can see, this is not super basic stuff. You don't want your game directly sending email because then you'd have to ship SMTP credentials in your binary (an instant recipe for disaster).
Well if a game server sends E-Mails though it would be useful to be able to do this directly from the NVGT server, with the SMTP credentials instead of having to have an API which is possibly way less secure, imo.
Yes I know all this, I will buy an SMTP server, but can I not do this in a simple way with the Curl library
I think curl can do it?
In my NVGTExport there is internet_request::bool mail(const string&in, conststring&in, const string&in, const string&in) const
sadly there is nowhere described what exactly this does.
in internet.h I found bool mail(const std::string& url, const std::string& from, const std::string& to, const std::string& payload);
No idea if it helps somehow, I don't have a lot of knowledge myself about that topic sadly so yeah, might be worth asking someone like Sam or another active cpp contributor.