Send an email from inside the game

Let me say this is more an experimental/theoretical idea, so I'm not sure if it will come useful for an actual game or something.
Nonetheless I found it interesting and I wanna know something more.

So: if the player puts his email address in a variable is there a way to make the game send a mail to that account?
If yes how?
I don't think that's possible without a plugin, so

I've moved this to Plugin Requests.

What did you want to use to actually send the email.
What did you want to use to actually send the email.
Mmmh not sure what you mean.
If you mean if I have any preferences on how technically do it, I guess I haven't (also cuz I'm too noob about javascript).
It can be a whole plugin or just a script call or whatever, BUT keep in mind that:

- the email address should be previously stored in a variable (I use a free input text plugin, so the mail address will be a string stored in a variable by the player)

- It should have enough flexibility to let me send more than just one pre-stored message; differents situations will send different mails.

- I don't think this must be said, but obviously it must be a method that allow me to send the message while playing (idk, through a npc maybe)

If this isn't enough clear or it doesn't answer your question just let me know. 😍
The email has to be sent from somewhere - an account. So, I believe that was the question.

You'd need the game to be "logged in" to an email address to send it from, or use a service to send it for you.
The email has to be sent from somewhere - an account. So, I believe that was the question.

You'd need the game to be "logged in" to an email address to send it from, or use a service to send it for you.
Oh 😅
Well I can make a gmail (or whatever is better in this case) account for the game itself, but can the game try to access it in order to send the message when I turn it on then?
Well, that is likely the largest part of the request, securely logging you in each time the game is turned on, so that when said event is triggered it can tell the connected email address who to send it to, and what to send.

Everything else is just filling out fields of strings that you put in your events, To: CC: Subject: Body: etc.

I know the workings of google scripts/suite that it would be fairly easy to do, once you can establish the connection with the account.

Note that somewhere in the code, you'll likely need to have the login credentials, so you are opening yourself up to someone searching through the code and taking over the account.

You could push the data through a form, which auto fires and email from the email address instead... Hmm...

I'd say it's possible, and likely the best route to go.
Well, that is likely the largest part of the request, securely logging you in each time the game is turned on, so that when said event is triggered it can tell the connected email address who to send it to, and what to send.

Everything else is just filling out fields of strings that you put in your events, To: CC: Subject: Body: etc.

I know the workings of google scripts/suite that it would be fairly easy to do, once you can establish the connection with the account.

Note that somewhere in the code, you'll likely need to have the login credentials, so you are opening yourself up to someone searching through the code and taking over the account.

You could push the data through a form, which auto fires and email from the email address instead... Hmm...

I'd say it's possible, and likely the best route to go.
Well, to be honest, this is something which is really far beyond my scripting abilities.
But if someone is interested in trying to do this plugin for me I will be really happy to purchase it! (Just let me know before, at least, a range of price for the job) ^^
Security will be an issue if you decide to let your client send emails.

OAuth solves that problem, but it will require users to grant access to their accounts before you can perform commands on their behalf.

If you aren't using their emails, you can just put it on a server and have the server send out emails. No security issues there except maybe people can abuse your email server.
it will require users to grant access to their accounts before you can perform commands on their behalf.
Why if users just have to receive the mail?
I think that only the game should have access to its own account in order to send the message, users can access their mail to check it whenever they want...

If you aren't using their emails, you can just put it on a server and have the server send out emails. No security issues there except maybe people can abuse your email server.
I can't create a dedicated server, it also needs a dedicated pc to stay always on if I'm not wrong.
It's a bit too complicated for me right now I guess 😅

Note that somewhere in the code, you'll likely need to have the login credentials, so you are opening yourself up to someone searching through the code and taking over the account.
This seems to me the better access solution, and if there is the possibility that the credentials are taken I'll just distribute this more complete version of the game only to people I really know...
I'm still interested in trying this idea even in case it would be just a personal experiment
Lol oops I just realized you only wanted to send email to the player.

OAuth might be OK for security. Basically, you give the game permission to send emails on your behalf. You don't include your credentials, you only include a public key and set it up so that only requests coming from the game will be accepted.

I'll see if I can get something working.
@Tsukihime, how about social media if you think the direct email might cause a security risk?
Because the devs in many mobile games have the report problem button where the information sends directly to the devs somehow.

I do not know the RPG Maker MV backbone enough to comment on the security risk, sorry.😢
Lol oops I just realized you only wanted to send email to the player.

OAuth might be OK for security. Basically, you give the game permission to send emails on your behalf. You don't include your credentials, you only include a public key and set it up so that only requests coming from the game will be accepted.

I'll see if I can get something working.
Thank you a lot!!!
Oh, a last minute question...
Could be possible to take the content of an email and store it in a variable? (I.e. If the player sent an answer to the game mail, basically the reverse procedure. This could lead to a "conversation" with cpu I guess).
However this last thing is surely secondary lol
I'm guessing when you make updates, you want the game to be able to send out a mass email?

Or are you making it like an MMO where players get notifications about expansions, nerfs, changes, etc. Because that would be pretty cool.

Try and give as much detail as possible. Someone will be more likely to help you as they will know what you need.
You want an automatic system? Or do you want to manually send them mails yourself?
There's a firebase plugin called online avatar(the system uses firebase but your game doesn't need to be an online game btw). You can ask the player to store their email addresses in a variable and since you're the owner of the database, you can see their addresses and send them mails yourself. This does feel sort of strange/not safe. I wouldn't want to enter my email address for an indie game personally... but people might, Idk. If you're interested but can't find it, I can send you the link to the plugin. I have to search for it first lol
I'm guessing when you make updates, you want the game to be able to send out a mass email?

Or are you making it like an MMO where players get notifications about expansions, nerfs, changes, etc. Because that would be pretty cool.

Try and give as much detail as possible. Someone will be more likely to help you as they will know what you need.

I need just what I wrote; the player will store the mail in a variable (specifically through a free input text plugin I'm already using), then when some events triggers the cpu (through its own mail account) will be able to send to that player account a pre-write text. And yes it could be also a notification of that kind.
Additionaly (even if secondary) I just thought/asked about the possibility to store back in a variable the text the player might send back as an answer, in order to simulate a conversation with the cpu (a npc maybe).
I think I have nothing more to ask, this will be already awesome!
I didn't thought about mass email sending and it isn't still strictly requested, but if it will be implemented nothing wrong with it😍

You want an automatic system? Or do you want to manually send them mails yourself?
There's a firebase plugin called online avatar(the system uses firebase but your game doesn't need to be an online game btw). You can ask the player to store their email addresses in a variable and since you're the owner of the database, you can see their addresses and send them mails yourself. This does feel sort of strange/not safe. I wouldn't want to enter my email address for an indie game personally... but people might, Idk. If you're interested but can't find it, I can send you the link to the plugin. I have to search for it first lol
I thank you but it doesn't seem what I need 🙏
Seriously, players won't, obviously, forced to give their mail in order to play, in addition, as I said, I'm taking this feature more like...uh...a personal sperimentation, at least for now!^^
However thanks
Bump!
There is someone interested in working on this? ^^
I tried this and it worked.
Edit: Forgot to mention. This won't work for browser deployment.

install nodemailer in your project's root folder.
Code:
npm install nodemailer
Sample code for sending email. You can use this from script call or turn this in to a plugin, whichever you prefer.
Spoiler
JavaScript:
var nodemailer = require('nodemailer');
var transporter = nodemailer.createTransport({
  service: 'gmail',
  auth: {
    user: '[email hidden]',
    pass: 'yourpassword'}});
var mailOptions = {
  from: '[email hidden]',to: '[email hidden]',subject: 'subject',text: 'content'};
transporter.sendMail(mailOptions, function(error, info){
  if (error) {
    console.log(error);
  } else {console.log('Email sent: ' + info.response);}});
Remember to change the address, password in the code.
***Note:
Your domain must be gmail. Otherwise this way won't work. Your players can use any other domains though like yahoo, outlook etc. So this won't be much of a problem.
Edit: It might work for others except gmail since there's a 'service' option in the code. But what changes you have to make for it to work in other services... I don't know.

Go to gmail, go to settings-->see all settings-->Forwarding and POP/IMAP-->Enable IMAP
Go to https://myaccount.google.com/lesssecureapps and allow less secure apps.

That's it. Now you can paste that code in to your script call and playtest it. Check the console (F8). It will let you know if your mail was sent or not.
If you have any questions feel free to ask.
THANKS! I'm going to try this tomorrow!
And yeah...I need some clarification on how to do this:

install nodemailer in your project's root folder.
Code:
npm install nodemailer

I don't know how to install npm modules, never used them before....😅
Sorry...the rest seems pretty clear
First you have to download node.js:
I'm also not good with command prompts so I just seached for cmd in my computer, and pasted it in to my projects root folder. Then I just opened that cmd and typed in npm install nodemailer. Hit enter and it will download everything necessary and put them in to a node_modules folder.

Original thread: https://forums.rpgmakerweb.com/threads/send-an-email-from-inside-the-game.124669/