HabitRPG / habitica

A habit tracker app which treats your goals like a Role Playing Game.
https://habitica.com
Other
11.95k stars 4.08k forks source link

How to connect to send e-mail? #12285

Closed sergey-prosvirnin closed 4 years ago

sergey-prosvirnin commented 4 years ago

Hello, can you tell us how to set up your mail service?

  1. In the config.json settings of the habitica project, should I explicitly specify the URL of my mail server with or without a port (e.g. https://mydomain.com or https://mydomain.com:3100 in EMAIL_SERVER_URL)?

  2. A similar question for the habitrpg-email-server project, what should I specify in BASE_URL, the URL of the habitica backend with or without port (e.g. https://mydomain.com or https://mydomain.com:3000)? If I understand correctly, can the habitrpg-email-server send mail only through the MANDRILL API?

  3. There is no way to use SMTP sending, it looks very strange that the OpenSource project uses a paid and proprietary API.

  4. If you really can send mail only through the MANDRILL API, then be sure to buy Standart and higher tariff plan what to unlock Transactional Email?

  5. And why do I need tokens AWS_, STRIPE_API_KEY, AMAZONPAYMENTS, PAYPAL, S3 in the project config.json for habitrpg-email-server ? Isn't it just a server for sending mail?

paglias commented 4 years ago

Hi @sergey-prosvirnin ,

  1. With the port, otherwise it'll use the default 80 port for HTTP connections and 443 for HTTPS 2 / 3. Same as before with the port. And yes the email server project only sends emails through Mandrill, SMTP is not supported. We use Mandrill to send emails from Habitica.com and due to the volume of emails using an SMTP server would be too complex for us to manage
  2. I'm sorry, can you clarify the question? I think Mandrill is now part of Mailchimp and in order to use it I think you'll also have to pay for a Mailchimp subscription
  3. Those env vars are necessary because the email server was originally only an email server but it 's now used to process other recurring jobs like payments, ....

To be honest this email server is, afaik, only used by Habitica.com and while the code is open source it was created for our own usage and not really meant to be used outside of Habitica.com, it contains a lot of custom code that getting it to work for your own instance of Habitica would be quite complex and probably not worth it. If you only need to send out emails my suggestion would be to fork the main habitica repo and replace the HTTP call used to send emails to this server with an SMPT module

sergey-prosvirnin commented 4 years ago

Hi @sergey-prosvirnin ,

  1. With the port, otherwise it'll use the default 80 port for HTTP connections and 443 for HTTPS 2 / 3. Same as before with the port. And yes the email server project only sends emails through Mandrill, SMTP is not supported. We use Mandrill to send emails from Habitica.com and due to the volume of emails using an SMTP server would be too complex for us to manage
  2. I'm sorry, can you clarify the question? I think Mandrill is now part of Mailchimp and in order to use it I think you'll also have to pay for a Mailchimp subscription
  3. Those env vars are necessary because the email server was originally only an email server but it 's now used to process other recurring jobs like payments, ....

To be honest this email server is, afaik, only used by Habitica.com and while the code is open source it was created for our own usage and not really meant to be used outside of Habitica.com, it contains a lot of custom code that getting it to work for your own instance of Habitica would be quite complex and probably not worth it. If you only need to send out emails my suggestion would be to fork the main habitica repo and replace the HTTP call used to send emails to this server with an SMPT module

Thank you for your clarification! I bought a key for the MANDRILL API and changed both config.json files, but unfortunately it did not work.

habitica config.json

  "EMAIL_SERVER_AUTH_PASSWORD": "*****",
  "EMAIL_SERVER_AUTH_USER":"*****",
  "EMAIL_SERVER_URL": "http://localhost:3100"

habitrpg-email-server config.json

  "PORT": 3100,
  "AUTH_USER": "*****",
  "AUTH_PASSWORD": "*****",
  "MANDRILL_API_KEY": "*****",
  "MONGODB_URL": "mongodb://localhost/habitrpg",
  "TEST_MONGODB_URL":"mongodb://localhost/habitrpg-email-server-test",
  "REDIS_PORT": 6379,
  "REDIS_HOST": "127.0.0.1",
  "BASE_URL": "http://localhost:3000",

Both APIs are available from localhost via curl.

curl http://localhost:3100
Unauthorized

curl http://localhost:3000
{"success":false,"error":"Error","message":"ENOENT: no such file or directory, stat '/home/liga/liga/website/client/dist/index.html'"}

The curl is also available through the MANDRILL API, for example I have successfully executed this request from the habitica and habitrpg-email-server, no calls to the MANDRILL API have been made before according to the MANDRILL web interface - https://www.mandrillapp.com/api/docs/users.curl.html#method-info

Apparently, habitica does not query the habitrpg-email-server and the latter does not send requests to the MANDRILL API. Is there any way to loging this? For example, it would be cool to see a request to reset an e-mail from habitica to the habitrpg-email-server. It would also be nice to see the log files of the habitrpg-email-server itself.

sergey-prosvirnin commented 4 years ago

Also an error about memory leak appears in logs of both components - https://gist.github.com/sergey-prosvirnin/18a99a0e6fd6aeb537a27c19619c43e0

I use Node.js v12.10.0 and have the following server configuration - https://gist.github.com/sergey-prosvirnin/f181b5f3001aacb79e173acac5cf2a85

paglias commented 4 years ago

The memory leak warning is just a default behavior by Node when more than 10 event listeners are added to an object, not an issue per se. Also I saw from the other comment that you've fixed the issue with emails not being sent so I'm going to close this issue