Postfix电子邮件转发

问题描述 投票:0回答:2

我在DigitalOcean有一个云服务器,在Namecheap有一个域。我将域名转移到了DigitalOcean。我想要的是设置电子邮件转发,例如

发送至[email protected]的电子邮件应转发至[email protected]

所以我做了你通常做的事情,当你想要做的事情,使用谷歌和寻找指南/教程,我发现这个:http://www.andreagrandi.it/2014/08/31/getting-started-with-digital-ocean-vps-configuring-dns-and-postfix-for-email-forwarding/

我跟着它并添加了DNS的东西(http://i.imgur.com/zKZm9C3.jpg?1)。 DigitalOcean还有一个“添加GMAIL MX记录”按钮,所以我点击它,这些在图像中标有红色矩形。

我安装了postfix,编辑了main.cf,我复制了andreagrandi的main.cf并用我的域名替换了他的域名。这就是我的main.cf的样子,但我刚才在这里使用mydomain是'匿名'。

# 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

myhostname = mydomain.com
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_una
***uth_destination <- I've removed this.***
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
virtual_alias_domains = mydomain.com
virtual_alias_maps = hash:/etc/postfix/virtual
myorigin = /etc/mailname
mydestination = mydomain, localhost.localdomain, localhost
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all

我要从main.cf中删除的一件事是

uth_destination,它在那里给了我一个错误信息。

postmap: fatal: /etc/postfix/main.cf, line 32: missing '=' after attribute name: "uth_destination"

我试图获得关于这个命令的一些信息,但我没有找到任何东西,就像postfix.org上的一个大沙漠对我来说。如果我添加“=”它会给我一个新的错误并告诉我它没有参数。

 /usr/sbin/postconf: warning: /etc/postfix/main.cf: unused parameter: uth_destination=

所以我认为最好只是删除它。

让我们继续。创建一个虚拟文件并进行编辑。

nano /etc/postfix/virtual

在我的虚拟文件中,我有以下内容

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

我保存了它,我可以使用l命令看到它。

cd /etc/postfix
l
dynamicmaps.cf  main.cf  master.cf  postfix-files  postfix-script*  post-install*  sasl/  virtual  virtual.db

然后我就运行这两个命令

sudo postmap /etc/postfix/virtual
sudo /etc/init.d/postfix reload

我得到一个[OK]回复。

当我尝试发送电子邮件到[email protected]时,我收到了

[email protected][email protected])发送状态通知(失败)

电子邮件永远不会发送到我的Gmail地址,现在我的wordpress-site上的联系表格也不起作用。我是Linux的初学者。

编辑:我可能在这里有点东西..

sudo netstat -ltnp | grep 25

tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN      1071/master
tcp6       0      0 :::25                   :::*                    LISTEN      1071/master

端口25标有RED。可能是因为它被关闭/阻止了吗?我在谷歌搜索它,似乎DigitalOcean为新用户阻止端口25?这可能是问题吗?

linux wordpress email dns
2个回答
0
投票
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN      1071/master

意味着该进程正在端口上进行侦听,您需要这个。

请添加postconf -ngrep contact /var/log/mail.log的输出

从该输出中获取ID,如下所示:

Jul 29 21:37:47 ent01 postfix/pickup[6214]: A34E3F40485: uid=0 from=<root>
Jul 29 21:37:47 ent01 postfix/cleanup[6538]: A34E3F40485: message-id=<20150730023747.A34E3F40485@ent01>
Jul 29 21:37:47 ent01 postfix/qmgr[1116]: A34E3F40485: from=<root@ent01>, size=263, nrcpt=1 (queue active)
Jul 29 21:37:47 ent01 postfix/local[6540]: A34E3F40485: to=<root@ent01>, orig_to=<root>, relay=local, delay=0.22, delays=0.16/0.01/0/0.06, dsn=2.0.0, status=sent (delivered to mailbox)
Jul 29 21:37:47 ent01 postfix/qmgr[1116]: A34E3F40485: removed

并做:

grep A34E3F40485 /var/log/mail.log

这可能会指向正确的方向,因为postfix日志记录在进行故障排除时非常有用。


0
投票

如果您使用的是Wordpress,则会有一个插件可以转发此电子邮件。您不需要为此任务安装Postfix。该插件名为Mailshogun,这正是它的作用。转发信息@ mydomain到[email protected]。然后,您可以使用“发送自”功能通过mydomain.com发回电子邮件。

© www.soinside.com 2019 - 2024. All rights reserved.