可以在Ubuntu 16.04中从smtp发送电子邮件,但无法从外部收到电子邮件

时间:2017-06-15 06:15:50

标签: ubuntu smtp postfix

我是初学者学习服务器。 我不知道它是否有用,我使用的是aws ec2和route53。 我正在尝试构建邮件服务器。 我可以成功向外界和本地发送邮件。 但是,我无法从外部接收邮件,例如Gmail,我也无法使用telnet访问端口110或143.

telnet inboxdrill.com 110
Trying 127.0.0.1...
Connected to inboxdrill.com.
Escape character is '^]'.
Connection closed by foreign host.

如果你让我知道我会很感激你的!请让我知道如何解决这个问题。

我的Ubuntu版本是:

Distributor ID: Ubuntu
Description:    Ubuntu 16.04.2 LTS
Release:    16.04
Codename:   xenial

当我检查tail -f /var/log/mail.log

 dovecot: master: Error: service(imap-login): command startup failed, throttling for 2 secs
 postfix/postscreen[26002]: CONNECT from [127.0.0.1]:42254 to [127.0.0.1]:25
 postfix/postscreen[26002]: WHITELISTED [127.0.0.1]:42254
 postfix/smtpd[26003]: warning: database /etc/postfix/virtual.db is older than source file /etc/postfix/virtual
 postfix/smtpd[26003]: warning: cannot get RSA certificate from file "/etc/ssl/private/server.crt": disabling TLS support
 postfix/smtpd[26003]: warning: TLS library problem: error:02001002:system library:fopen:No such file or directory:bss_file.c:398:fopen('/etc/ssl/private/server.crt','r'):
 postfix/smtpd[26003]: warning: TLS library problem: error:20074002:BIO routines:FILE_CTRL:system lib:bss_file.c:400:
 postfix/smtpd[26003]: warning: TLS library problem: error:140DC002:SSL routines:SSL_CTX_use_certificate_chain_file:system lib:ssl_rsa.c:701:
 postfix/smtpd[26003]: connect from inboxdrill.com[127.0.0.1]
 postfix/smtpd[26003]: disconnect from inboxdrill.com[127.0.0.1] quit=1 commands=1

这是master.cf代码:

smtp      inet  n       -       y       -       -       smtpd
smtp      inet  n       -       y       -       1       postscreen
smtpd     pass  -       -       y       -       -       smtpd
#dnsblog   unix  -       -       y       -       0       dnsblog
#tlsproxy  unix  -       -       y       -       0       tlsproxy
submission inet n       -       y       -       -       smtpd
  -o syslog_name=postfix/submission
  -o smtpd_tls_security_level=encrypt
  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_reject_unlisted_recipient=no
#  -o smtpd_client_restrictions=$mua_client_restrictions
#  -o smtpd_helo_restrictions=$mua_helo_restrictions
#  -o smtpd_sender_restrictions=$mua_sender_restrictions
#  -o smtpd_recipient_restrictions=
  -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
  -o milter_macro_daemon_name=ORIGINATING
smtps     inet  n       -       y       -       -       smtpd
  -o syslog_name=postfix/smtps
  -o smtpd_tls_wrappermode=yes
  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_reject_unlisted_recipient=no
#  -o smtpd_client_restrictions=$mua_client_restrictions
#  -o smtpd_helo_restrictions=$mua_helo_restrictions
#  -o smtpd_sender_restrictions=$mua_sender_restrictions
#  -o smtpd_recipient_restrictions=
  -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
  -o milter_macro_daemon_name=ORIGINATING

这是main.cf:

#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/private/server.crt
smtpd_tls_key_file = /etc/ssl/private/server.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 = inboxdrill.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = $myhostname, inboxdrill.com, ip-172-31-7-112.us-west-1.compute.internal, localhost.us-west-1.compute.internal, localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
#mynetworks = this is my ip/24
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
home_mailbox = Maildir/

# added
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_local_domain =
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_sasl_auth_enable = yes
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
smtp_tls_security_level = may
smtpd_tls_security_level = may
smtp_tls_note_starttls_offer = yes
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes


mailbox_command =
smtpd_sasl_local_domain =
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
smtpd_tls_auth_only = no
smtp_use_tls = yes
smtpd_tls_note_starttls_offer = yes
smtpd_tls_CAfile = /etc/ssl/certs/cacert.pem
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
virtual_alias_maps = hash:/etc/postfix/virtual

1 个答案:

答案 0 :(得分:0)

我在aws route53上添加了MX记录,也是A记录。 您应该为A记录的值添加DNS ipv4,并应为example 10 yourdomain.com的MX记录值添加优先级和邮件服务器域。

最重要的是,您应该在aws安全组上打开SMTP,SMTPS,IMAP,IMAPS,POP3,POP3等端口。您可以在ec2选项卡上找到它并编辑入站规则。

我是服务器的新手,如果有人认为它不正确而且不够,那么请回复我和其他人。

我很高兴自己解决这个问题。我可以从外面接收电子邮件,也可以发送电子邮件。 :d 我希望这对像我这样的新手有用。 :)