为什么我需要用户名和名称向 Gmail smtp 服务器发送电子邮件的密码
我想使用 node.js 创建一个简单的 smtp 代理,它接收邮件然后将它们发送到自定义 Gmail 帐户。但是当我连接到 Gmail smtp 服务器时,我需要使用用户名和地址进行身份验证。密码。但是:发送者如何知道接收者的用户名和密码?
为什么我的 smtp 客户端无法在没有此类身份验证的情况下向 Gmail 地址发送电子邮件?
我错过了什么吗?
我的代码:
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:<[email protected]>\r\n");
});
});
c.on("data",function(d){
console.log(d+"");
});
});
输出:
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
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:<[email protected]>\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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您使用了错误的服务器。 smtp.gmail.com 用于中继 Gmail 用户的出站电子邮件,并要求他们进行身份验证。发送至 Gmail 用户的入站电子邮件应通过 gmail.com 的 MX 记录中指定的服务器,该服务器不需要身份验证 - 目前此类服务器的最高优先级是 gmail-smtp-in.l.google.com,但该服务器随时可能改变。
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.
你误会了。您需要的是 SMTP 服务器的一些有效凭据集,告诉服务器您实际上已被授权使用它。经过身份验证和授权后,您可以使用 SMTP 服务器向任何人发送电子邮件。
SMTP 服务器过去对任何人都是完全免费的,但由于发送未经请求的电子邮件的滥用行为猖獗,许多大型 SMTP 服务器已开始只接受注册用户。
对于 GMail,您需要提供您自己的帐户详细信息。或者,您可以寻找不需要身份验证的其他 SMTP 服务器。您的网络托管服务商通常会为您提供一个。
You're misunderstanding. What you do need is some valid set of credentials for the SMTP server that tells the server that you are in fact authorized to use it. Once you're authenticated and authorized, you can use the SMTP server to send email to anyone.
SMTP servers used to be completely freely available to anyone, but because of rampant abuse for sending unsolicited emails, many big SMTP servers have started admitting only registered users.
For GMail, you would supply your own account details. Or, you could just look for a different SMTP server that doesn't require authentication. Your web host would typically provide you with one.
垃圾邮件。如果任何人都可以通过谷歌的邮件服务器发帖而无需以某种方式进行身份验证,那么他们就只是一个(大规模)垃圾邮件中继。
当您向 SMTP 服务器进行身份验证时,您不需要收件人的帐户信息,而是需要一些有关您自己的凭据来授权发送/中继。
SPAM. If anyone could post through google's mail servers without authenticating one way or another, they'd just be a (massive) spam relay.
When you authenticate to an SMTP server, you don't need the account info of the recipient, but some credentials about yourself to authorize the send/relay.