将 Postfix 配置为 25 以外的端口

将 Postfix 配置为 25 以外的端口

我已经在 Google 上搜索了不少有关如何重新配置​​ Postfix 以在不同端口上工作的信息,但我仍然无法在我的 master.cf 中找到人们一直在谈论的那几行。我使用的是 OS X Mountain Lion,我的 ISP 在端口 25 上阻止了双向流量。

人们说要寻找这样一行字

smtp  inet  n  -  n  -  -  smtpd

我找不到它。

这是(我认为)未经修改的

# ==== Begin auto-generated section ========================================
# This section of the master.cf file is auto-generated by the Server Admin
#  Mail backend plugin whenever mails settings are modified.
smtp      inet  n       -       n       -       1       postscreen
smtpd     pass  -       -       n       -       -       smtpd
dnsblog   unix  -       -       n       -       0       dnsblog
tlsproxy  unix  -       -       n       -       0       tlsproxy
submission inet  n       -       n       -       -       smtpd
  -o smtpd_tls_security_level=encrypt
smtp      unix  -       -       n       -       -       smtp
# === End auto-generated section ===========================================
# Modern SMTP clients communicate securely over port 25 using the STARTTLS command.
# Some older clients, such as Outlook 2000 and its predecessors, do not properly
# support this command and instead assume a preconfigured secure connection
# on port 465. This was sometimes called "smtps", but such usage was never
# approved by the IANA and therefore conflicts with another, legitimate assignment.
# For more details about managing secure SMTP connections with postfix, please see:
#   http://www.postfix.org/TLS_README.html
# To read more about configuring secure connections with Outlook 2000, please read:
#   http://support.microsoft.com/default.aspx?scid=kb;en-us;Q307772
# Apple does not support the use of port 465 for this purpose.
# After determining that connecting clients do require this behavior, you may choose
# to manually enable support for these older clients by uncommenting the following
# four lines.
#465        inet  n       -       n       -       -       smtpd
#  -o smtpd_tls_wrappermode=yes
#  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
#  -o milter_macro_daemon_name=ORIGINATING
#628       inet  n       -       n       -       -       smtp
pickup    fifo  n       -       n       60      1       pickup
cleanup   unix  n       -       n       -       0       cleanup
qmgr      fifo  n       -       n       300     1       qmgr
#qmgr     fifo  n       -       n       300     1       oqmgr
tlsmgr    unix  -       -       n       1000?   1       tlsmgr
rewrite   unix  -       -       n       -       -       trivial-rewrite
bounce    unix  -       -       n       -       0       bounce
defer     unix  -       -       n       -       0       bounce
trace     unix  -       -       n       -       0       bounce
verify    unix  -       -       n       -       1       verify
sacl-cache unix -       -       n       -       1       sacl-cache
flush     unix  n       -       n       1000?   0       flush
proxymap  unix  -       -       n       -       -       proxymap
proxywrite unix -       -       n       -       1       proxymap
# When relaying mail as backup MX, disable fallback_relay to avoid MX loops
relay     unix  -       -       n       -       -       smtp
        -o smtp_fallback_relay=
#       -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq     unix  n       -       n       -       -       showq
error     unix  -       -       n       -       -       error
retry     unix  -       -       n       -       -       error
discard   unix  -       -       n       -       -       discard
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       n       -       -       lmtp
anvil     unix  -       -       n       -       1       anvil
scache    unix  -       -       n       -       1       scache
#
# ====================================================================
# Interfaces to non-Postfix software. Be sure to examine the manual
# pages of the non-Postfix software to find out what options it wants.

========编辑=========

澄清一下,我不需要接收邮件,我只需要发送邮件,只要我向每个电子邮件客户端(yahoo、gmail、hotmail、aol、cox 等)发送邮件即可。这篇文章的目的是,如果您的端口 25 被阻止,则可以从 Ruby 或 PHP 发送邮件。

答案1

你想达到什么目的?

入站邮件:其他 SMTP 服务器(外部)需要端口 25 才能向您发送邮件。即使您将端口更改为 - 比如说 25250 - 其他人也不知道他们需要访问此端口来发送邮件你。

出站邮件:您的服务器不使用端口 25 作为发送邮件的源端口。它使用端口 25 作为(外部)服务器上的目标端口。无论您尝试在本地配置哪个端口,都无法影响外部世界。

通过(外部)智能主机中继邮件:如果服务器智能主机在不同的端口接受邮件,就这样做。http://www.postfix.org/postconf.5.html#relayhost

答案2

因此,事实证明,cox 只会阻止端口 25 上不往返于 cox 服务器的流量,因此解决这个问题的最简单方法是进入 main.cf 并设置中继主机。幸运的是,cox 允许您使用其服务器smtp.cox.net,该服务器在端口 25 上进行监听。

relayhost = [smtp.cox.net]:25

答案3

您正在使用端口 587(提交),而不是 25,这是现在正确的端口。如果客户端尚未自动执行此操作,则需要配置客户端以使用端口 587。

您需要看到的行是:

submission inet  n       -       n       -       -       smtpd

就这一点而言,您的配置看起来还不错。

答案4

为了完整起见,你看不到一条线

smtp  inet  n  -  n  -  -  smtpd

因为你在master.cf跑步后屏幕在 Postfix 前面:

smtp  inet  n  -  n  -  1  postscreen
smtpd  pass -  -  n  -  -  smtpd

相关内容