title: How to send emails from my server with a mail server and nodejs
body: <p>I have a server with static IP in my home, I serve my own web pages with a domain and all works fine.</p>
  
  <p>in my web pages, you can register by email and password. when you register a node module called nodemailer, sends an email from a google account, the problem is that the google account has a limit of the sent emails.</p>
  
  <p>so I need to connect the nodemailer module to a server in my own home.</p>
  
  <p>I search on google but nothing similar has the answer.</p>
  
  <p>how to use postfix with nodejs??</p>
  
  <p><a href="http://www.postfix.org/" rel="noreferrer">http://www.postfix.org/</a></p>
  
  <p>or how to use haraka module with nodemailer</p>
  
  <p><a href="https://github.com/baudehlo/Haraka" rel="noreferrer">https://github.com/baudehlo/Haraka</a></p>
  
  <p>so I repeat my question, I need to send an email from my server to any email user that register in my web.</p>
  
  <p>for example...</p>
  
  <p>user jose@gmail.com register in my web</p>
  
  <p>nodemailer configuration is...</p>
  
  <pre><code>exports.newRegistration=function(parametros,callback)
  {
      var mailOptions = 
      {
          from: "&lt;myemailingoogle@gmail.com&gt;",//my email
          to: parametros.useremail,//user email
          subject: 'Welcome '+parametros.useremail+'.',
          html:   '&lt;br&gt;&lt;b&gt;Hello&lt;/b&gt;&lt;br&gt;'+ // html 
  
      };
      var smtpTransport = nodemailer.createTransport("SMTP",
      {
          service: "Gmail",
          secureConnection: true,
          auth:
          {
              user: "myemailingoogle@gmail.com",
              pass: "7ftera359c28a",
          },
      });
      smtpTransport.sendMail(mailOptions, function(err, response)
      {
          if(err)
          {
              smtpTransport.close();
              console.warn(err);
              return callback(err,null);
          }else{
              smtpTransport.close();
              return callback(null,response);
          }
      });
  }
  </code></pre>
  
  <p>the email sends ok, but it has a limit per day.</p>
  
  <p>so I need to use an email server to send my emails with no limit.... tnx</p>
  
  <p>EDIT 2</p>
  
  <p>i install mailutils with apt-get</p>
  
  <p>and now i try </p>
  
  <pre><code>mail mymailin@gmail.com
  Cc: // press enter
  Subject: Welcome
  
  Hello Mail.
  
  // Ctrl+D
  </code></pre>
  
  <p>this sends emails to my mailbox and I receive in SPAM an email sent from root@mail.mydomain.com</p>
  
  <p>so, postfix is working, but I still can't send emails with emailjs or nodemailer...</p>
  
  <p>when I try to send emails with emails or nodemailer I get this</p>
  
  <pre><code>smtp: '535 5.7.8 Error: authentication failed: generic failure\n'
  </code></pre>
  
  <p>I search in google that error and is and auth login error, I can't login to the system.
  so I try with telnet</p>
  
  <pre><code>telnet localhost 25
  ehlo localhost
  250-mydomain.com
  250-PIPELINING
  250-SIZE 10240000
  250-VRFY
  250-ETRN
  250-STARTTLS
  250-AUTH PLAIN LOGIN
  250-AUTH=PLAIN LOGIN
  250-ENHANCEDSTATUSCODES
  250-8BITMIME
  250 DSN
  mail to: myuserin@gmail.com
  501 5.5.4 Syntax: MAIL FROM:&lt;address&gt;
  mail from: info@mydomain.com
  250 2.1.0 Ok
  rcpt to: myuserin@gmail.com
  451 4.3.0 &lt;myuserin@gmail.com&gt;: Temporary lookup failure
  data
  554 5.5.1 Error: no valid recipients
  AUTH LOGIN
  503 5.5.1 Error: MAIL transaction in progress
  </code></pre>
  
  <p>I try again</p>
  
  <pre><code>220 mydomain.com ESMTP Postfix (Ubuntu)
  ehlo localhost
  250-mydomain.com
  250-PIPELINING
  250-SIZE 10240000
  250-VRFY
  250-ETRN
  250-STARTTLS
  250-AUTH PLAIN LOGIN
  250-AUTH=PLAIN LOGIN
  250-ENHANCEDSTATUSCODES
  250-8BITMIME
  250 DSN
  AUTH LOGIN
  334 VXNlcm5hbWU6
  UbuntuUser
  535 5.7.8 Error: authentication failed: another step is needed in authentication
  </code></pre>
  
  <p>and again with root </p>
  
  <pre><code>220 mydomain.com ESMTP Postfix (Ubuntu)
  ehlo localhost
  250-mydomain.com
  250-PIPELINING
  250-SIZE 10240000
  250-VRFY
  250-ETRN
  250-STARTTLS
  250-AUTH PLAIN LOGIN
  250-AUTH=PLAIN LOGIN
  250-ENHANCEDSTATUSCODES
  250-8BITMIME
  250 DSN
  auth login
  334 VXNlcm5hbWU6
  root
  334 UGFzc3dvcmQ6
  rootPassword
  535 5.7.8 Error: authentication failed: another step is needed in authentication
  </code></pre>
  
  <p>this is the log file</p>
  
  <pre><code>Jun 20 15:50:16 myname postfix/smtpd[12528]: warning: localhost[127.0.0.1]:             SASL login authentication failed: another step is needed in authentication
  </code></pre>
  
  <p>and that's it... where is the problem in this???</p>