juanluisbaptiste/docker-postfix

Example of how to use it as a smtp server

MontoyaAndres opened this issue · 1 comments

What I mean with this is that I want to use this image to send emails with a web page in localhost, I've configured the image like this:

sudo run --name postfix -p "25:25" --net=host -e SMTP_SERVER=localhost -e SMTP_USERNAME=andres -e SMTP_PASSWORD=password -e SERVER_HOSTNAME=127.0.0.1 -e SMTP_NETWORKS='192.168.0.0/24' juanluisbaptiste/postfix

And then, I use node.js as a client, with the Nodemailer library, like this:

const nodemailer = require("nodemailer");

const transporter = nodemailer.createTransport({
  host: "localhost",
  port: 25,
  auth: {
    user: "andres",
    pass: "password"
  },
  secure: false
});

transporter.sendMail({
  from: "test@example.com",
  to: "andresmontoyafcb@gmail.com",
  subject: "Hello ✔",
  text: "Hello world?",
  html: "<b>Hello world?</b>"
});

But it doesn't work, the error that nodemailer throws me is:

Screenshot_2019-08-28_17-20-52

Might you help me? Thank you!

It can't be used as a mail server, it only works as a relay. If you took the time to read the README file you should have noticed that the variables SMTP_USERNAME and SMTP_PASSWORD are for setting the credentials for the external SMTP server that is being used as a relay, not to set a username and password to be set on the container.