AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1003171
Accepted
Nathaniel Alconcel
Nathaniel Alconcel
Asked: 2020-02-15 19:26:18 +0800 CST2020-02-15 19:26:18 +0800 CST 2020-02-15 19:26:18 +0800 CST

Postfix smtp 中继可以发送邮件但不能中继其他主机

  • 772

用例:我们有几个不支持 SSL/TLS 身份验证的伊顿 PDU/PSU。我的任务是构建一个 SMTP 中继服务器,它可以接收基本的 SMTP/25 电子邮件并通过 SSL 将它们转发给我们的电子邮件提供商。

注意:中继主机使用 stunnel 在 465 上建立 smtps 连接。

我的 SMTP Postfix 中继服务器能够通过我们的电子邮件提供商 alimail 成功发送邮件。但我无法让它中继来自我们网络上其他主机的电子邮件。

/etc/postfix/main.cf

smtpd_banner = mail01v-la ESMTP
inet_interfaces = all
inet_protocols = ipv4

mynetworks = 127.0.0.0/8, 10.96.80.0/24
relayhost = [127.0.0.1]:5000
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CApath = /etc/ssl/certs
smtp_use_tls = no
smtp_generic_maps = regexp:/etc/postfix/generic

/etc/postfix/sasl_passwd

[127.0.0.1]:5000 [email protected]:notifypwd

/etc/后缀/通用

/^root@(.*)$/ [email protected]

/etc/stunnel/stunnel.conf

client = yes
foreground = no

[smtps]
accept = 5000
connect = smtp.mxhichina.com:smtps

SMTP Telnet 到提供商

[root@mail01v-la ~]# telnet smtp.mxhichina.com smtp
Trying 205.204.101.152...
Connected to smtp.mxhichina.com.
Escape character is '^]'.
220 smtp.aliyun-inc.com MX AliMail Server
ehlo google.come
250-smtp.aliyun-inc.com
250-STARTTLS
250-8BITMIME
250-AUTH=PLAIN LOGIN XALIOAUTH
250-AUTH PLAIN LOGIN XALIOAUTH
250-PIPELINING
250 DSN

检查通道连接

[root@mail01v-la ~]# telnet 127.0.0.1 5000
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
220 smtp.aliyun-inc.com MX AliMail Server

从中继服务器发送电子邮件

echo "Stack Body" | mail -s "Test Subject for Stack" [email protected]

结果

Feb 14 18:30:29 mail01v-la postfix/pickup[4812]: 3194940DE2: uid=0 from=<root>
Feb 14 18:30:29 mail01v-la postfix/cleanup[4865]: 3194940DE2: message-id=<[email protected]>
Feb 14 18:30:29 mail01v-la postfix/qmgr[2606]: 3194940DE2: from=<[email protected]>, size=481, nrcpt=1 (queue active)
Feb 14 18:30:30 mail01v-la postfix/smtp[4867]: 3194940DE2: to=<[email protected]>, relay=127.0.0.1[127.0.0.1]:5000, delay=1.3, delays=0.01/0.01/0.85/0.46, dsn=2.0.0, status=sent (250 Data Ok: queued as freedom)
Feb 14 18:30:30 mail01v-la postfix/qmgr[2606]: 3194940DE2: removed

电子邮件

与其他主机一起测试

随机 CentOS 服务器

/etc/postfix/main.cf

relayhost = [10.96.80.126]:5000

结果

Feb 14 18:06:52 test01v-la postfix/pickup[1247]: BB87C305A42F: uid=0 from=<root>
Feb 14 18:06:52 test01v-la postfix/cleanup[1387]: BB87C305A42F: message-id=<[email protected]>
Feb 14 18:06:52 test01v-la postfix/qmgr[1248]: BB87C305A42F: from=<[email protected]>, size=477, nrcpt=1 (queue active)
Feb 14 18:06:53 test01v-la postfix/smtp[1389]: BB87C305A42F: to=<[email protected]>, relay=10.96.80.126[10.96.80.126]:5000, delay=0.78, delays=0.01/0.01/0.61/0.15, dsn=5.0.0, status=bounced (host 10.96.80.126[10.96.80.126] said: 553 authentication is required (in reply to MAIL FROM command))

伊顿电源

配置 信用

伊顿结果

email[17131]: message error -110 in function smtp_start_session test - (Connection timed out) retrying smtp_start_session test email[17131]: Failed to connect to SMTP server 10.96.80.126:5000 with username [email protected]

__

这是我第一次做这样的设置。我的知识中可能有很多漏洞让我感到悲伤。

  1. 在正确的设置中,您是否甚至需要为想要使用中继服务器的任何主机重新键入凭据?例如,在eaton smtp 配置中,它应该是sasl 文件中使用的电子邮件的凭据吗?还是允许使用后缀转发的系统帐户?或者后缀/通用文件中定义的帐户名称?有点失落。

  2. stunnel 甚至是我应该通过 ssl/tls 连接的正确方式吗?我在 smtp.mxhichina.com 的 telnet 提示符中看到了 starttls。

老实说,我认为我过于复杂了,或者遗漏了一些明显的东西。如果有人有更好的设置来适应我的用例,也将不胜感激。


仅将 SSL 连接从 Stunnel 切换到 Postfix

结果

Feb 20 11:27:22 mail01v-la postfix/qmgr[1537]: 6B38AE5EE: from=<[email protected]>, size=479, nrcpt=1 (queue active)
Feb 20 11:27:22 mail01v-la postfix/smtp[1558]: CLIENT wrappermode (port smtps/465) is unimplemented
Feb 20 11:27:22 mail01v-la postfix/smtp[1558]: instead, send to (port submission/587) with STARTTLS
Feb 20 11:27:40 mail01v-la postfix/smtp[1558]: 6B38AE5EE: to=<[email protected]>, relay=smtp.mxhichina.com[205.204.101.152]:465, delay=613, delays=595/0.02/19/0, dsn=4.4.2, status=deferred (lost connection with smtp.mxhichina.com[205.204.101.152] while receiving the initial server greeting)
Feb 20 11:32:22 mail01v-la postfix/qmgr[1537]: A3F736B2: from=<[email protected]>, size=477, nrcpt=1 (queue active)

主文件

inet_interfaces = all
inet_protocols = ipv4

mynetworks = 127.0.0.0/8, 10.96.80.0/24
relayhost = [smtp.mxhichina.com]:465
smtp_use_tls = yes
smtp_enforce_tls = yes
smtp_tls_wrappermode = yes

soft_bounce = yes
smtp_sasl_auth_soft_bounce = yes

/etc/postfix/sasl_passwd

smtp.mxhichina.com [email protected]:notifypwd
smtp postfix centos7 stunnel smtps
  • 4 4 个回答
  • 2005 Views

4 个回答

  • Voted
  1. davidgo
    2020-02-16T11:59:54+08:002020-02-16T11:59:54+08:00

    你的线路

      mynetworks = 127.0.0.0/8, 10.96.80.1/24
    

    看起来不正确 - 您指定了一个主机(不确定它如何解释关联的网络。)尝试将第二个条目更改为 10.96.80。0 /24

    • 0
  2. Tomek
    2020-02-19T12:34:29+08:002020-02-19T12:34:29+08:00

    据我所知

    smtp_sasl_auth_enable = yes
    smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
    

    当 postfix 充当 SMTP 客户端而不是服务器并启用 postfix 本身对远程服务器的身份验证时使用。http://www.postfix.org/SASL_README.html中的更多详细信息。

    我认为你应该启用

    smtpd_sasl_auth_enable = yes
    

    并查看上述自述文件的“在 Postfix SMTP 服务器中启用 SASL 身份验证和授权”部分。

    • 0
  3. Anderson Medeiros Gomes
    2020-02-20T01:35:19+08:002020-02-20T01:35:19+08:00

    除非您使用的是旧的 Postfix 版本,否则您不需要配置stunnel为使用 SSL/SMTPS 与您的电子邮件提供商通信。Postfix >= 3.0 可以通过在您的 中设置以下参数来直接执行此操作/etc/postfix/main.cf:

    relayhost = [smtp.mxhichina.com]:465
    smtp_use_tls = yes
    smtp_enforce_tls = yes
    smtp_tls_wrappermode = yes
    
    # Optional, but recommended to prevent mail loss
    soft_bounce = yes
    smtp_sasl_auth_soft_bounce = yes
    

    然后,在您的 中/etc/postfix/sasl_passwd,定义以下条目:

    smtp.mxhichina.com [email protected]:notifypwd
    

    更改/etc/postfix/sasl_passwd文件后,请确保postmap /etc/postfix/sasl_passwd已运行命令行。此外,运行命令行postmap -q smtp.mxhichina.com hash:/etc/postfix/sasl_passwd以确保身份验证凭据已正确存储。

    参考:http ://www.postfix.org/TLS_README.html#client_smtps


    关于 Eaton PSU 和您网络中的其他 CentOS 服务器,我相信您只需将中继服务器的地址和端口设置25/tcp为 SMTP 服务器/中继主机:

    relayhost = [10.96.80.126]:25
    

    通过这样做,Postfix 服务器将使用普通和未经身份验证的 SMTP 连接接收电子邮件,将它们存储在自己的电子邮件队列中,然后使用 SSL/SMTPS 连接和适当的凭据将消息转发给您的提供商。

    • 0
  4. Best Answer
    Nathaniel Alconcel
    2020-02-26T18:55:37+08:002020-02-26T18:55:37+08:00

    感谢大家的帮助。我最初的设置是正确的,除了我试图从其他客户端连接的端口,它应该是 25,而不是 5000。

    前任。在随机 CentOS 服务器中:

    /etc/postfix/main.cf
    
    relayhost = [10.96.80.126]:25
    

    伊顿不工作的原因是因为网络没有在 /etc/postfix/main.cf 的 mynetworks 中定义,并且因为我的 OOB 网络的路由问题。

    谢谢大家的帮助。

    • 0

相关问题

  • Postfix 或 exim:自动/程序化和转发电子邮件设置

  • 如何将 SMTP 直接从 IIS 6.0 服务器中继到 Exchange 2003 服务器

  • 使用 telnet 或 netcat 发送带有附件的电子邮件

  • 我应该使用什么策略在 linux 上安装 smtp 服务器?用于多线程服务

  • 适用于 Linux 的 SMTP 服务器,配置简单

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve