node.js - Nodemailer with Docker -


i'm trying send emails docker container running express through register365.

this code used

export class emailer { transporter: nodemailer.transporter; constructor() {     this.transporter = nodemailer.createtransport(smtptransport({         host: 'smtp.reg365.net',         auth: {             user: 'myuser',             pass: mypassword'         }     })); }  public async sendemail(to,body) {     try {         return await this.transporter.sendmail({to,from: '"test" <user@myuser.ie>',text: body, subject: ' need content , design of email!!!!'});     }     catch(error) {         console.log('email error');         console.dir(error);     }  } } 

that's working fine if run express npm start if run docker it'll fail error error: connection closed

it fails using smtp.reg.356.net, if use gmail it'll work perfectly

this docker file i'm using

from  node:8  run mkdir -p /usr/src/app workdir /usr/src/app  run npm install -g nodemon  copy package.json /usr/src/app/ run npm install  copy ./dist /usr/src/app/dist  expose 3005 expose 25 cmd [ "npm", "start" ] 

many thanks.

edit: requested, running telnet smtp.reg365.net 25 returns telnet: not resolve smtp.reg.356.net/25: name or service not known

output of cat /etc/resolv.conf on host machine

domain hitronhub.home nameserver 89.101.160.5 nameserver 89.101.160.4 

on docker container

search hitronhub.home nameserver 127.0.0.11 options ndots:0 

create file /etc/docker/daemon.json

{ "dns": ["89.101.160.5", "89.101.160.4"] } 

restart docker service , try again , see if works you.

you on office network has own dns servers should using. need tell docker daemon dns server containers should using. creating issue. daemon.json file can used change daemon configuration.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -