nodejs创建服务器
In this article, I will show you how simple it is to create an SMTP server using NodeJS and be up and running in a few minutes. You can then send emails to your node application, either as a method of remote control or for 1001 other reasons.
在本文中,我将向您展示使用NodeJS创建SMTP服务器并在几分钟内启动并运行它是多么简单。 然后,您可以将电子邮件作为远程控制方法或出于其他1001个原因而发送到节点应用程序。
An SMTP receives emails from other email servers or email clients. If you want an application to process emails in realtime, then your own SMTP server is the way to go. Writing your own server provides some added benefits, like being able to use your own domain name with unlimited email addresses at no extra cost.
SMTP接收来自其他电子邮件服务器或电子邮件客户端的电子邮件。 如果您希望应用程序实时处理电子邮件,那么您便可以使用自己的SMTP服务器。 编写自己的服务器具有一些额外的好处,例如能够免费使用具有无限电子邮件地址的自己的域名。
There is a bit more work to get it up and running, but I promise, it’s not that much.
要启动并运行还需要做更多的工作,但是我保证,这还不算什么。
您将需要什么。 (What you're going to need.)
- Your own domain name with the ability to edit DNS records. 您自己的域名,可以编辑DNS记录。
- NodeJS 节点JS
- A fixed IP Address 固定IP地址
- If you're on a home network you will need to be able to set up port forward rules on your Internet Router. 如果您在家庭网络中,则将需要能够在Internet路由器上设置端口转发规则。
DNS设置 (DNS setup)
In order for a domain to receive emails, it needs to know about the mail server that will handle incoming email.
为了使域接收电子邮件,它需要了解将处理传入电子邮件的邮件服务器。
I already have a domain hackmail.net
which I will use as an example throughout this tutorial.
我已经有一个域名hackmail.net
,在本教程中将作为示例。
Here is how you need to configure your domain records. I use 123-reg.co.uk
for domain registration. They provide their own guide on mail server setup. Your registrar may have a similar guide.
这是您需要配置域记录的方式。 我使用123-reg.co.uk
进行域名注册。 他们提供有关邮件服务器设置的指南 。 您的注册商可能有类似的指南。
第1步 (Step 1)
Delete any existing MX
records on your domain.
删除您域中所有现有的MX
记录。
第2步 (Step 2)
Add a new A
record that points to your internet router IP Address.
添加一个新的A
记录, A
记录指向您的Internet路由器IP地址。
Hostname: mail
Type: A
Desination IP Address: <Your routers Public IP Address>
第三步 (Step 3)
Create a new MX
record that points to the fully qualifi