我应该使用什么SMTP端口?

我应该使用什么SMTP端口?

我应该使用什么SMTP端口?

Apr 20, 2020

出版商

出版商

Bird

Bird

-

类别

类别

电子邮件

电子邮件

Ready to see Bird
in action?

Ready to see Bird
in action?

What SMTP Port Should I Use?

我应该使用哪个SMTP端口。端口25、465、587或2525?

人们在配置一个应用程序或邮件系统来发送(或中转)电子邮件时,经常会有一个共同的问题。"我应该使用什么SMTP端口?"你可能会看到一些信息,告诉你使用端口25、465、587或2525进行SMTP中继。那么,哪一个应该是你的标准SMTP端口?下面是你需要知道的内容,以及为什么。


什么是SMTP端口?

SMTP (Simple Mail Transfer Protocol) is the basic standard that mail servers use 在互联网上相互发送电子邮件. SMTP is also used by applications such as Apple Mail or Outlook to upload emails to mail servers that then relay them to other mail servers. (On the other hand, mail apps typically rely on other standards such as IMAP or POP3 to retrieve emails from servers.)

Like other Internet services such as web sites, SMTP email relies on domain names and Internet addresses to know where to send messages. All of us today are familiar with the textual version of these addresses, like www.sparkpost.com. Most of us know that the text address stands in for a numeric IP address like 107.21.246.67. But not as many of us know that these network addresses 还包括具体的 "端口号"。 An “SMTP port” refers 到 specific part of the Internet address that’s used to transfer email.

网络和HTTP使用80号端口。对于电子邮件和SMTP,该端口号是......嗯,这取决于。


SMTP与SSL和TLS有什么不同?

这两种技术都有助于电子邮件的发送。虽然SMTP可能是这个过程的肌肉和骨骼,但安全套接字层(SSL)形成了皮肤,以保持你的电子邮件安全。SSL适用于任何可用的端口。

在不太遥远的过去,SSL是普通电子邮件端口的首选标准安全协议。随着其新的和改进的后代--传输层安全(TLS)的采用,电子通信变得更加安全。

While both protocols create a private channel between the sending and receiving computer to secure transmissions, TLS offers more alerts than its ancestor and can execute more hash functions to enhance encrypted communication. Today, many emails use the most up-to-date convention, STARTTLS, which combines with either SSL or TLS protocols for maximum security.

SMTP协议本身并不像它能做到的那样安全。将该传输方式与其中一个安全协议结合使用,可以提供更多的加密保护。对于发送电子邮件,SSL和其他协议加强了SMTP的传输。


怎样才能知道你的SMTP端口是什么?

如果你订阅了一个托管的电子邮件中继服务,你可以从你的电子邮件服务的支持页面获得SMTP服务器的主机名和端口号。

如果运行的是自己的 SMTP 服务器,则可以从 SMTP 服务器配置中找到配置的 SMTP 端口号和地址。在PowerMTA 中,您可以从配置文件中配置的 "smtp-listener "指令中找到这些信息。配置文件可在 Linux 服务器上的 /etc/pmta/config 和 Windows 服务器上的 C:\pmta\config.dat 中找到。

smtp-listener 10.0.1.22:587 # 监听端口587和IP 10.0.1.22


你应该为SMTP使用哪个端口?

Ports 25, 465, 587, or 2525 for SMTP have all been considered standard SMTP ports at some point, but only 587 or 2525  really should be considered for modern use.

如果您将您的系统配置为使用SparkPost作为SMTP中继,您应该使用端口587作为您的标准SMTP端口,2525作为备用,以备端口587不可用。

在我们了解今天发送电子邮件常用的不同端口时,我将解释原因。


端口25:最初的标准SMTP端口

Port 25 is the original standard email SMTP port and the oldest, since it first debuted in 1982. Today, the 互联网号码分配机构(IANA), the group responsible for maintaining the internet addressing scheme, still recognizes port 25 as the standard, default SMTP port. SMTP was designated to use port 25 in IETF Request For Comments (RFC) 821. But in practicality, it’s not as simple as it seems.

Although port 25 continues to be used for server-to-server SMTP relaying, most modern SMTP clients should not be configured to use this port. Port 25 is usually blocked by residential ISPs and business cloud hosting providers alike because it earned a bad reputation as the preferred port for spammers sending massive quantities of unsolicited communications.


为什么端口25通常被封锁?如何检查它是否被封锁?

端口25在许多网络上被封锁,以遏制从被攻击的计算机或服务器转发的垃圾邮件的数量。除非你专门管理一个邮件服务器,否则你的电脑或服务器上不应该有任何流量穿越这个端口。

要检查端口25是否被ISP封锁了。

  1. 如果你使用的是Windows,打开你的命令提示符。如果你使用的是Mac,打开你的终端。如果你使用的是Linux,请打开你的终端仿真器。

  2. 输入以下命令:telnet examplemailserver.com 25

如果端口25没有被封锁,你应该收到类似这样的信息。

user@localhost:~# telnet gmail-smtp-in.l.google.com 25 Trying 1.2.3.4...连接到gmail-smtp-in.l.google.com。220 mx.google.com ESMTP 123si3448417qkd.359 - gsmtp

如果你收到与下面类似的信息,那么端口25很可能被封锁了。

telnet:连接到地址XX.XX.XX:连接被拒绝 telnet。无法连接到远程主机


你什么时候会使用端口25?

Port 25 is the default port for relaying email on the internet. However, you can specify any port number (Provided it is within the acceptable range of custom port numbers) for submitting emails to your SMTP server. 

在有些特殊情况下,你必须在你的SMTP服务器上使用端口25。其中一种情况是接收带外/异步弹出。这种退信发生在事后。这意味着收件人域名接受了来自你的SMTP服务器的邮件,但后来又将邮件退回。带外退信被异步发送至原始邮件的返回路径(MAIL FROM)地址。收件人域将尝试把这些退信发送到返回路径地址的MX服务器和25号端口(因为25号端口是互联网上转发电子邮件的默认端口)。另一个例子是接收回馈环路(FBL)。

通过配置 "smtp-listener "指令,您可以启用端口 25,以便在PowerMTA 服务器上接收邮件。

smtp-listener 10.0.1.22:25    # listens on port 25 and IP 10.0.1.22


端口465。废弃的和过期的SMTP端口

Port 465 is no longer an accepted standard for SMTP. However, there are some legacy systems that still use port 465 for SMTP, and some help pages on the internet still suggest port 465 as the recommended setup. ǞǞǞ port gained redundancy in the late 1990s but still relies on the passive implicit SSL method for establishing secure transmission. Our advice? Don’t do it unless your application absolutely requires it.

IANA最初为SMTP的一个加密版本分配了465端口,称为SMTPS。最初,它被建议使用安全套接字层(SSL)来发送电子邮件。然而,IANA后来将这个端口重新分配给不同的用途,所以它不应该再被用于SMTP。这就是为什么SparkPost不接受465端口的连接。


端口587。标准的安全SMTP端口

现代的电子邮件服务器使用端口587来安全地提交电子邮件进行传递。例如,如果你使用Outlook或Apple Mail等电子邮件客户端软件,它很可能被配置为使用这个端口来发送你的信息。然而,这不仅仅是个人电子邮件客户端软件。向像SparkPost这样的电子邮件发送服务传输信息的系统也应配置为使用该端口。

所有SparkPost的客户都应该使用端口587作为默认值,除非您的上游网络或主机提供商明确阻止了您。使用587端口,加上TLS加密,是确保电子邮件安全和可靠地提交给SparkPost(或几乎任何其他供应商)的最佳方式。


端口2525:一个常见的备用SMTP端口

2525端口不是一个正式的SMTP端口,它没有被IETF或IANA认可。然而,SparkPost和许多其他电子邮件服务提供商支持使用2525端口作为SMTP的587端口的替代品,如果上述端口被封锁的话(一个明显的例子是在谷歌计算引擎上托管的服务需要这样做)。如果你已经尝试过端口587,但遇到连接问题,请尝试端口2525。就像端口587一样,大多数监听端口2525的实现也支持TLS加密。


SMTP端口是否重要?

除了连接方面的挑战外,你会发现使用不正确的端口会影响发送能力。电子邮件通信只有在发件人和收件人之间找到它的方式时才会有效,而正确的端口可以确保成功交付。

对于大多数用户来说,你的电子邮件提供商将为你配置端口,所以你不需要选择。但是,对于其他人来说,重要的是要了解,有不同的功能分配给各种不同的端口,主要分为提交和中继。


提交和转发

提交是指你将你新造的电子通信交给你的电子邮件服务提供商的发件箱的行为。如果你和你的供应商在不同的端口上,这个过程就会停止--你的电子邮件不会再进一步。当在同一端口时,你的邮件服务器接受外发通信并与另一端的计算机握手。当一切都安全并达成一致时,传输就发生了。这个过程被称为中继。


什么是SMTP服务器?

SMTP 服务器是为电子邮件客户端发送、接收和/或转发外发邮件时使用的协议提供动力的计算机。在此过程中,SMTP 服务器会验证发件人是否被允许通过 SMTP 发送邮件,如果发件人被允许发送邮件,但邮件被认为无法送达,SMTP 服务器会将邮件发回 MAIL FROM 地址。PowerMTA 是领先的 SMTP 服务器之一,因为它允许发件人采用最新的验证规范发送大量邮件,并符合新的验证政策。


如何设置你的SMTP服务器

在设置 SMTP 服务器时,有两种选择可供探索。您可以订购托管电子邮件中继服务。SparkPost 是一家领先的电子邮件发送和分析服务提供商。或者,您也可以设置自己的 "内部 "SMTP 服务器,以实现更精细的控制。PowerMTA 就是一个例子。

To stand up a PowerMTA server, contact support@port25.com for installation package, license and installation instructions. All PowerMTA configuration is done within the config file which is found in /etc/pmta/config on a Linux server and C:\pmta\config.dat on Windows Server.

对于你的SMTP服务器的基本配置,有几个注意事项和步骤要做。

  1. 您希望您的 SMTP 服务器使用哪个 IP 地址和端口号接收电子邮件?端口 25 是电子邮件中继的默认端口。在PowerMTA 中,您可以通过编辑配置文件中的 "smtp-listener "指令来更改默认端口号。smtp-listener 0/0:25 # 监听所有本地 IP 的端口 25。您还可以指定 IP 地址的 CIDR 范围

    or

    smtp-listener 10.0.1.22:25 # 监听端口 25 和 IP 10.0.1.22

  2. You must permit relaying of messages from your email client to your SMTP server. Your SMTP server should NEVER be an open relay. This means you must somehow selectively allow relaying. In PowerMTA there are a few ways to do this.You can authenticate with username and password. PowerMTA supports authentication with either LOGIN, PLAIN or the CRAM-MD5 mechanism for inbound connections. This is configured within the smtp-user and source stanza of the config file. For a user “foo” and password “barbaz”<smtp-user foo> password barbaz authentication-method password #certificate (TLS) or system(linux user) are other options </smtp-user> #Then require authentication 在 source stanza <source 0/0> require-auth true </source>

    你也可以有选择地允许从一个特定的IP地址或CIDR范围进行中继。这将是你的电子邮件客户端的IP地址。

    <source 10.0.5.20> always-allow-relaying yes # allow feeding from 10.0.5.20 </source>

    您还可以设置PowerMTA 将接受电子邮件的收件人域名/地址(或模式)。

    # 允许将邮件中转到一些.domain的中转域 some.domain的中转地址 bounce@bounce.yourdomain.com relay-address /@foo(bar)?\.com$/ # regex模式

  3. Another consideration is if you want to securely relay emails from your email client to your SMTP server (Inbound TLS)? If your answer is yes then you must enable STARTTLS for inbound connections and configure a TLS certificate. In PowerMTA TLS is supported from TLSv1 to TLSv1.3.smtp-server-tls-certificate /etc/pmta/yourcert.pem #Enable TLS on inbound connections <source 0/0> allow-starttls true require-starttls-before-auth true #ensures authentication information is only sent over tls </source>

  4. Do you want your SMTP server to securely deliver emails to remote servers (Outbound TLS)? In PowerMTA you have the option to use TLS if the remote server supports it or to enforce TLS and drop the connection if TLS is not supported by the remote server.<domain *> # (*) is a wildcard for all recipient domain use-starttls true #uses TLS if available require-starttls true #enforces TLS </domain>

  5. 设置 SMTP 服务器发送 SMTP 连接的 IP 地址和主机名。在PowerMTA 中,这是通过 smtp-source-host 指令设置的。 smtp-source-host 192.168.0.10 mail10.yourserver.com #您也可以指定 CIDR 范围

  6. 最后,PowerMTA 还有一个非常独特的功能,那就是可以通过建立多归属主机来分离邮件流。PowerMTA 中的 VirtualMTA 技术允许用户定义和控制每个邮件流的源 IP 地址、主机名和邮件发送参数。这样就可以创建单独和特定的campaigns 、客户或部门,同时仍然只运行一个PowerMTA 实例。

<virtual-mta mta1> smtp-source-host 1.2.3.4 mta1.yourserver.com <domain *> use-starttls true require-starttls true retry-after 10m </domain> </virtual-mta> <virtual-mta mta2> smtp-source-host 2.3.4.5 mta2.yourserver.com <domain *> use-starttls false require-starttls false retry-after 45m </domain> </virtual-mta>

当基本设置完成后,你可以向你的SMTP服务器配置的主机名/IP和端口号(上面例子中的10.0.1.22:25)提交邮件,并根据你允许提交邮件的方式,用配置的用户名(foo)和密码(barbaz)进行验证。

综上所述,SMTP端口587几乎是连接SparkPost和其他电子邮件交付服务的所有使用情况的最佳选择。

我希望这些信息能帮助你了解更多关于使用哪一个SMTP端口的信息!


了解更多

Want to learn more about using SMTP? Here are instructions for configuring SparkPost for SMTP relay and email delivery, the differences between SMTP and API message transmission, and troubleshooting your SMTP connection to SparkPost. Your team of professionals at SparkPost is also available to provide technical support when needed.

Your new standard in Marketing, Pay & Sales. It's Bird

ǞǞǞ right message ->right person ->right time.

By clicking "See Bird" you agree to Bird's 隐私声明.

Your new standard in Marketing, Pay & Sales. It's Bird

The right message -> to the right person -> at the right time.

By clicking "See Bird" you agree to Bird's 隐私声明.