Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
650 views
in Technique[技术] by (71.8m points)

nodemailer - Send mail from docker container, host with NGINX and reverse proxy

I've configured NGINX in a cloud instance with reverse proxy to a docker container. The app sends emails using nodemailer - Gmail SMTP but isn't working inside a docker container.

My guess:

  • Missing ports configurations
  • A mail proxy or something is needed...

I tried exposing ports 587 and 465 in the Dockerfile with no success (Not sure if that's correct or if I need something else).

Other considerations:

  • The container runs it's own server using Koa.
  • The cloud instance will host more containers that may send mail too. Each with their own domain and reverse proxy configurations.

Your help is really appreciated!

UPDATE

Running the app in the container: Gmail is giving a 534 response code (invalid login error) Still working fine runnning the app outside the container.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Gmail authentication was giving login errors running the app in the container. The correct way is to configure it through OAuth2 and it works flawlessly.

Here's the tutorial I found that helped me out: https://alexb72.medium.com/how-to-send-emails-using-a-nodemailer-gmail-and-oauth2-fe19d66451f9

Thanks timsmelik for your help.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...