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 / 问题 / 848029
Accepted
Waqas Tariq
Waqas Tariq
Asked: 2017-05-04 06:53:09 +0800 CST2017-05-04 06:53:09 +0800 CST 2017-05-04 06:53:09 +0800 CST

Postfix 延迟发送电子邮件

  • 772

我在 Amazon Lightsail 上运行 Ubuntu 16.04。我只是将 Postfix 配置为发送电子邮件。

  • 如果我在几个小时后发送电子邮件,则会立即收到电子邮件。

  • 如果我同时发送多封电子邮件,电子邮件会延迟大约 10-30 分钟。

问题:

  1. 如何修复延迟以便立即发送电子邮件?
  2. 如何确保本地应用程序发送给用户(root 和 ubuntu)的所有电子邮件都发送到具有相同域的外发电子邮件?

我的配置:

/etc/resolv.conf

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 172.x.x.x
search ec2.internal

/etc/hosts

127.0.0.1       localhost
127.0.1.1       webserver.DOMAIN-NAME.com webserver
3x.x.x.x        webserver.DOMAIN-NAME.com webserver #3.x.x.x is the IP that is mentioned in domain DNS

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

/etc/主机名

webserver

/etc/别名

postmaster:    root
root:          [email protected]

/etc/postfix/main.cf

# See /usr/share/postfix/main.cf.dist for a commented, more complete version


# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = webserver.DOMAIN-NAME.com
mydomain = DOMAIN-NAME.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
#myorigin = /etc/mailname
myorigin = $mydomain
#mydestination = $myhostname, DOMAIN-NAME.com, webserver.DOMAIN-NAME.com, localhost.DOMAIN-NAME.com, localhost
mydestination =
#relayhost =
relayhost = $mydomain
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
#inet_interfaces = all
inet_interfaces = loopback-only
#inet_protocols = all
inet_protocols = ipv4

/var/log/mail.log

May  1 02:17:15 webserver postfix/smtp[6105]: 0287CC775F: to=<[email protected]>, relay=alt1.aspmx.l.google.com[64.233.190.27]:25, delay=531, delays=465/0.01/64/1.9, dsn=2.0.0, status=sent (250 2.0.0 OK 1493605035 h2si13051738qte.100 - gsmtp)
May  1 02:17:15 webserver postfix/qmgr[6102]: 0287CC775F: removed
May  1 02:17:40 webserver postfix/smtp[6107]: connect to alt1.aspmx.l.google.com[64.233.190.27]:25: Connection timed out
May  1 02:17:40 webserver postfix/smtp[6108]: connect to alt1.aspmx.l.google.com[64.233.190.27]:25: Connection timed out
May  1 02:18:10 webserver postfix/smtp[6108]: connect to aspmx2.googlemail.com[64.233.190.27]:25: Connection timed out
May  1 02:18:10 webserver postfix/smtp[6107]: connect to aspmx3.googlemail.com[209.85.203.26]:25: Connection timed out
May  1 02:18:40 webserver postfix/smtp[6108]: connect to aspmx3.googlemail.com[209.85.203.26]:25: Connection timed out
May  1 02:18:40 webserver postfix/smtp[6107]: connect to aspmx2.googlemail.com[64.233.190.27]:25: Connection timed out
May  1 02:18:40 webserver postfix/smtp[6108]: CBE50C77C6: to=<[email protected]>, relay=none, delay=7845, delays=7695/0.02/150/0, dsn=4.4.1, status=deferred (connect to aspmx3.googlemail.com[209.85.203.26]:25: Connection timed out)
May  1 02:18:40 webserver postfix/smtp[6107]: 2266DC775D: to=<[email protected]>, relay=none, delay=174, delays=24/0.01/150/0, dsn=4.4.1, status=deferred (connect to aspmx2.googlemail.com[64.233.190.27]:25: Connection timed out)
May  1 02:20:02 webserver postfix/scache[6110]: statistics: start interval May  1 02:16:41
May  1 02:20:02 webserver postfix/scache[6110]: statistics: domain lookup hits=0 miss=1 success=0%
May  1 02:20:02 webserver postfix/scache[6110]: statistics: address lookup hits=0 miss=2 success=0%
May  1 02:20:02 webserver postfix/scache[6110]: statistics: max simultaneous domains=1 addresses=1 connection=1
May  1 02:26:10 webserver postfix/qmgr[6102]: 2266DC775D: from=<[email protected]>, size=425, nrcpt=1 (queue active)
May  1 02:26:10 webserver postfix/smtp[6138]: 2266DC775D: to=<[email protected]>, relay=aspmx.l.google.com[209.85.201.26]:25, delay=625, delays=624/0.01/0.09/0.18, dsn=2.0.0, status=sent (250 2.0.0 OK 1493605570 p15si12740899qta.122 - gsmtp)
May  1 02:26:10 webserver postfix/qmgr[6102]: 2266DC775D: removed
email
  • 1 1 个回答
  • 11837 Views

1 个回答

  • Voted
  1. Best Answer
    Esa Jokinen
    2017-05-04T22:33:49+08:002017-05-04T22:33:49+08:00

    Amazon Lightsail 是面向 Web 应用程序开发人员的低端低价云 VPS 解决方案。Lightsail 文档中的所有内容都与选择和配置 Web 服务器和 CMS 平台有关。没有明确说明,但很明显 Lightsail 不适合作为电子邮件服务器。甚至您的服务器的名称也是webserver!

    Web 应用程序可能会每隔一段时间发送一封电子邮件。因此 SMTP 端口 25 并没有被完全封锁,而是有一些限制。您的 Postfix 配置对于独立的 SMTP 服务器来说是可以的,但mail.log显示了正在发生的事情:达到限制后,SMTP 连接超时并且邮件获取deferred,推迟到稍后尝试。基于RFC 3463的SMTP 状态代码 dsn=4.4.1说明相同:

    4.4.1 收件人的服务器没有响应

    这是从您的服务器发出的错误,表明收件人的服务器没有响应。您的服务器将自动重试多次 - 多少次取决于您的服务器的配置方式。

    您在评论中提到,这只发生在 Ubuntu 上的 Postfix 上,而不是 Amazon Linux 上的 Sendmail 上。我对 Amazon Linux 和 Amazon SES不太熟悉,但我猜 Amazon Linux Sendmail 可能会将 Amazon SES 预配置为中继。也可以将 Amazon SES 与 Postfix 集成。

    正如您所拥有的那样relayhost = $mydomain,您可能正在尝试将所有邮件中继到您域的外部邮件服务器,因为它应该是。但是,端口限制25对于您的外部 MTA 也不例外。因此,您应该改用消息提交代理(端口587)。

    1. 您必须在电子邮件服务器中配置 MSA。如果它也是 Postfix,你应该有以未注释/etc/postfix/master.cf开头的部分:submission

       submission inet n       -       -       -       -       smtpd
         -o syslog_name=postfix/submission
         -o smtpd_tls_security_level=encrypt
         -o smtpd_sasl_auth_enable=yes
         -o smtpd_client_restrictions=permit_sasl_authenticated,reject
         -o milter_macro_daemon_name=ORIGINATING
      
    2. 配置您的 Lightsailrelayhost以使用提交端口和身份验证,main.cf:

       relayhost = $mydomain:587
       # Alternative example without DNS MX lookup:
       # relayhost = [mail.example.com]:587
       smtp_sasl_auth_enable = yes
       smtp_sasl_security_options = noanonymous
       smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
       smtp_use_tls = yes
       smtp_tls_security_level = encrypt
       smtp_tls_note_starttls_offer = yes
      
    3. 这/etc/postfix/sasl_passwd是用于与邮件网关服务器进行身份验证的用户名和密码信息的Berkeley DB ( hash:)。例子:

       # destination                   credentials
       [mail.example.com]              username:password
       # Alternative form:
       # [mail.example.com]:submission username:password
      

    有关更多详细信息,请参阅Postfix SASL Howto。

    • 1

相关问题

  • 如何绕过 ISP 的限制性电子邮件政策?

  • SharePoint 传入电子邮件出现“未知别名”错误

  • 电子邮件帐户的角色名称与人名

  • 如何在笔记本电脑上使用 Tobit David?[关闭]

  • 随行人员通过 VPN 连接到 Exchange 2007

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