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 / 问题 / 471255
Accepted
Steve Bennett
Steve Bennett
Asked: 2013-01-22 19:59:40 +0800 CST2013-01-22 19:59:40 +0800 CST 2013-01-22 19:59:40 +0800 CST

用于基于别名转发的简单 SMTP 服务器

  • 772

我正在寻找一个仅用于转发几个电子邮件地址的 SMTP 服务器。两个要求:

  1. 易于在 Ubuntu 上安装和配置。
  2. 有一个易于自动添加的别名文件。理想情况下,它应该是一个文本文件,由诸如“[email protected] [email protected]”之类的行组成。
  3. (理想情况下)可以轻松配置为仅接受来自特定主机的邮件。

我一直在尝试 Postfix,但我陷入了诸如 和 之类的错误消息Recipient address rejected: User unknown in virtual alias table中Recipient address rejected: User unknown in local recipient table。所以我想知道是否有更简单的解决方案。

email
  • 2 2 个回答
  • 4032 Views

2 个回答

  • Voted
  1. Best Answer
    John Siu
    2013-01-22T20:48:35+08:002013-01-22T20:48:35+08:00
    1. 使用后缀

      在 ubuntu 上,执行以下操作

      apt-get install postfix
      

      我正在对我的 vps 电子邮件设置做完全相同的事情。查看我的博客文章Tiny VPS Postfix。我正在复制下面的例子

      /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.
      
      myhostname = <YOUR HOSTNAME>
      alias_maps = hash:/etc/aliases
      alias_database = hash:/etc/aliases
      myorigin = /etc/mailname
      mydestination = <YOUR DOMAIN NAME>, localhost.domain, localhost
      relayhost =
      mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
      mailbox_command = procmail -a "$EXTENSION"
      mailbox_size_limit = 0
      recipient_delimiter = +
      inet_interfaces = all
      
      smtpd_recipient_restrictions =
          permit_mynetworks,
          permit_sasl_authenticated,
          reject_invalid_hostname,
          reject_non_fqdn_hostname,
          reject_non_fqdn_sender,
          reject_non_fqdn_recipient,
          reject_unknown_recipient_domain,
          reject_unlisted_recipient,
          reject_unauth_destination,
          reject_rbl_client cbl.abuseat.org,
          reject_rbl_client bl.spamcop.net,
          reject_rbl_client relays.mail-abuse.org,
          reject_rbl_client dnsbl.proxybl.org,
          reject_rbl_client truncate.gbudb.net,
          reject_rbl_client dnsbl.njabl.org,
          permit
      

      记得改变<YOUR HOSTNAME>和<YOUR DOMAIN NAME>

    2. 别名文件

      您的/etc/aliases文件应如下所示

      foo: [email protected]
      bar: [email protected]
      

      左侧应该没有域名,只有用户名。该域由您的后缀配置控制。然后做以下

      cd /etc
      postalias aliases
      service postfix restart
      
    3. 单主机限制

      为了只允许来自一个(或几个)主机的电子邮件,我将使用一种非常懒惰的方式来做到这一点。

      假设允许传入主机的IP为192.168.1.100,将其添加到mynetworks

      mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 192.168.1.100
      

      更改smtpd_recipient_restrictions为以下

      smtpd_recipient_restrictions =
          permit_mynetworks,
          reject_unlisted_recipient
      

      Postfix 仅(并且始终)接受来自 . 中列出的主机的电子邮件mynetworks。并拒绝其他一切。

    4. 域名系统配置

      请记住设置 MX 记录和 spf 记录。

    • 5
  2. KodeTitan
    2013-01-22T21:06:55+08:002013-01-22T21:06:55+08:00

    我以类似的方式使用 Postfix 转发到另一台服务器。使用三个配置选项,但对于您的配置,有一种更简单的方法。

    • relay_recipient_maps = ldap:/etc/postfix/ldap_relay_recipients_maps.cf
    • transport_maps = ldap:/etc/postfix/ldap_transport_maps.cf
    • 中继域 = ldap:/etc/postfix/ldap_relay_domains.cf

    我的一个 LDAP 文件看起来像这样用于查询 Zimbra 上的 LDAP 源...

    server_host=ldap://[mail.domain.com]:389
    server_port=389
    search_base=
    query_filter = (&(|(zimbraMailDeliveryAddress=%s)(zimbraMailAlias=%s)(zimbraMailCatchAllAddress=%s))(zimbraMailStatus=enabled))
    result_attribute = zimbraMailDeliveryAddress,zimbraMailAlias
    version = 3
    ldap_cache = yes
    ldap_cache_expiry = 600
    ldap_cache_size = 64256
    bind = yes
    bind_dn = uid=[valid login],cn=[valid cn],cn=[valid cn]
    bind_pw = [a valid password]
    timeout = 30
    

    但是,根据您正在寻找的内容,将信息保存在可用于此目的的本地哈希表中会更容易。您唯一需要记住的是,当您对文件进行更改时,您需要重新运行 postmap 来构建 postfix 友好的哈希表。

    • relay_recipient_maps = hash:/etc/postfix/relay_recipients_maps
    • relay_domains = fwddomain.com
    • transport_maps = hash:/etc/postfix/transport_maps

    您需要在上述位置使用以下条目对创建一个文本文件:{[电子邮件地址] OK}

    [email protected] OK
    [email protected] OK
    [email protected] OK
    

    在上面的文件上运行 postmap 以生成实际的哈希文件,然后在与 relay_recipients_maps.db 相同的文件夹中创建该文件。Postfix 现在将检查此文件以查找有效的收件人以进行传递。

    然后,您需要告诉 Postfix 在收到电子邮件时将此域的电子邮件发送到哪里。对 /etc/postfix/transport_maps 文件做同样的事情,你可以输入有效的对,它们是电子邮件要去的域和转发它的主机。

    fwddomain.com      smtp:mail.fwddomain.com
    

    希望这可以帮助您指明正确的方向。关于如何在 Internet 上执行这些类型的配置文件的更多信息,其他人甚至可以使用数据库来查找这些配置选项。

    • 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