I want to create a simple smtp proxy using node.js, which receives mails and then sends them to a custom Gmail account. But when I connect to the Gmail smtp server, I need an authentication with username & password. BUT: How should the sender know the username and password of the receiver?
Why isn´t my smtp client able to send an email to a Gmail address without such an authentication?
Have I missed something?
My code:
var tls = require("tls");
var fs = require("fs");
var o = {
cert:fs.readFileSync("/certificate.pem"),
key:fs.readFileSync("/key.pem")
};
var c = tls.connect(465,"smtp.gmail.com",o,function(){
c.once("data",function(d){
c.write("HELO cloudstudios.ch\r\n");
c.once("data",function(d){
c.write("MAIL FROM:<test@cloudstudios.ch>\r\n");
});
});
c.on("data",function(d){
console.log(d+"");
});
});
output:
220 mx.google.com ESMTP u14sm14212124eeh.1
250 mx.google.com at your service
530-5.5.1 Authentication Required. Learn more at
530 5.5.1 http://mail.google.com/support/bin/answer.py?answer=14257 u14sm14212124eeh.1
You’re using the wrong server. smtp.gmail.com is for relaying outbound email from Gmail users, and requires them to authenticate. Inbound email to Gmail users should go via the servers specified in the MX record for gmail.com, which don’t require authentication — the highest priority such server at present is gmail-smtp-in.l.google.com, but that is liable to change at any time.