Ubuntu/Postfix not receiving emails from outside

Prasad Rajapaksha asked:

I am trying to configure my Amazon EC2 instance to receive emails with postfix. I tried for hours but I never received an email. If I send email from same server terminal it works. This is working

echo "My message" | mail -s subject [email protected] 

But if I try to send email from outside like gmail. I don’t receive it. My port 25 is open. I am not receiving any delivery failed messages too. Couldn’t find anything related issue from postfix log too. Appriciate if someone can help me to figure out the issue.

Here is my postfix config file.

# 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_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 = example.com
virtual_alias_maps = hash:/etc/postfix/virtual
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = example.com
relayhost =
mynetworks = [::ffff:]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
alias_maps = hash:/etc/aliases

enter image description here

As Alex suggested the swaks output as bellow.

=== Trying
=== Connected to
<-  220 example.com ESMTP Postfix (Ubuntu)
 -> EHLO ip-172-31-21-89.ap-southeast-2.compute.internal
<-  250-example.com
<-  250-SIZE 10240000
<-  250-VRFY
<-  250-ETRN
<-  250-STARTTLS
<-  250-8BITMIME
<-  250 DSN
 -> MAIL FROM:<[email protected]>
<-  250 2.1.0 Ok
 -> RCPT TO:<[email protected]>
<-  250 2.1.5 Ok
 -> DATA
<-  354 End data with <CR><LF>.<CR><LF>
 -> Date: Sat, 12 Mar 2016 23:08:43 +1100
 -> To: [email protected]
 -> From: [email protected]
 -> Subject: Test
 -> X-Mailer: swaks v20130209.0 jetmore.org/john/code/swaks/
 -> This is a test mailing
 -> .
<-  250 2.0.0 Ok: queued as E44EE642AD
 -> QUIT
<-  221 2.0.0 Bye

And I have received that email. Then again I tried sending an email form my Gmail. Unfortunately it failed. And when I try to check my [email protected] email from here. It says “Bad” http://verify-email.org/

My answer:

Your MX record points to the name smtp.example.com, but this name doesn’t have any address records.

$ host example.com
example.com has address
example.com mail is handled by 10 smtp.example.com.

$ host smtp.example.com
Host smtp.example.com not found: 3(NXDOMAIN)

Mail for your domain is therefore undeliverable.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.