1

On my Linode I followed this doc to setup a mail server.

Now I can send email to any domain but can't receive from other domains!
I mean [email protected] can recieve from [email protected] but can't recieve any mail from xxx@gmail/yahoo/...com. I checked my vmail (Maildir) too, mails from other domains aren't there.

I received Delivery Status Notification (Delay) from gmail(after about 24 hrs):

Delivery to the following recipient has been delayed:
[email protected]
Message will be retried for 2 more day(s)
Technical details of temporary failure: 
The recipient server did not accept our requests to connect. Learn more at http://mail.google.com/support/bin/answer.py?answer=7720 
[mail.mydomain.com. (10): Connection refused]

And it's my settings:
I have a MX Record:

mail.mydomain.com

and an A/AAAA Records:

mail (with same ip as my server)  

My /etc/hosts

127.0.0.1       localhost.localdomain   localhost
(server ip)     hostname.mydomain.com  hostname

My /etc/default/saslauthd

START=yes
DESC="SASL Authentication Daemon"
NAME="saslauthd"
MECHANISMS="pam"
MECH_OPTIONS=""
THREADS=5
OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd -r"

My /etc/aliases

postmaster: root
root: [email protected]

My /usr/share/postfix/main.cf

protocols = imap imaps pop3 pop3s
log_timestamp = "%Y-%m-%d %H:%M:%S "
mail_location = maildir:/home/vmail/%d/%n/Maildir

ssl_cert_file = /etc/ssl/certs/dovecot.pem
ssl_key_file = /etc/ssl/private/dovecot.pem

namespace private {
    separator = .
    prefix = INBOX.
    inbox = yes
}

protocol lda {
    log_path = /home/vmail/dovecot-deliver.log
    auth_socket_path = /var/run/dovecot/auth-master
    postmaster_address = [email protected]
    mail_plugins = sieve
    global_script_path = /home/vmail/globalsieverc
}

protocol pop3 {
    pop3_uidl_format = %08Xu%08Xv
}

auth default {
    user = root

    passdb sql {
        args = /etc/dovecot/dovecot-sql.conf
    }

    userdb static {
        args = uid=5000 gid=5000 home=/home/vmail/%d/%n allow_all_users=yes
    }

    socket listen {
        master {
            path = /var/run/dovecot/auth-master
            mode = 0600
            user = vmail
        }

        client {
            path = /var/spool/postfix/private/auth
            mode = 0660
            user = postfix
            group = postfix
        }
    }

My /usr/share/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 = /usr/share/doc/postfix

# TLS parameters
smtpd_tls_cert_file = /etc/postfix/smtpd.cert
smtpd_tls_key_file = /etc/postfix/smtpd.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 = hostname.mydomain.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = hostname.mydomain.com, localhost, localhost.localdomain
relayhost =
mynetworks = 127.0.0.0/8
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = (server ip), 127.0.0.1
html_directory = /usr/share/doc/postfix/html
message_size_limit = 30720000
virtual_alias_domains =
virtual_alias_maps = proxy:mysql:/etc/postfix/mysql-virtual_forwardings.cf, mysql:/etc/postfix/mysql-virtual_email2email.cf
virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql-virtual_domains.cf
virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailboxes.cf
virtual_mailbox_base = /home/vmail
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
smtpd_sasl_authenticated_header = yes
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destinationvirtual_create_maildirsize = yes
virtual_maildir_extended = yes
proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps        $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $virtual_mailbox_limit_maps
virtual_transport = dovecot
dovecot_destination_recipient_limit = 1

My iptables rules:
(I use 2525 instead of 25 port and it's open in my machine and isp, i can telenet on it)

 pkts bytes target     prot opt in     out     source               destination         
  130  7820 ACCEPT     tcp  --  any    any     anywhere             anywhere            tcp dpt:smtp 
    0     0 ACCEPT     udp  --  any    any     anywhere             anywhere            udp dpt:25 
  388 33099 ACCEPT     tcp  --  any    any     anywhere             anywhere            tcp dpt:2525 
    0     0 ACCEPT     udp  --  any    any     anywhere             anywhere            udp dpt:2525 
    0     0 ACCEPT     udp  --  any    any     anywhere             anywhere            udp dpt:100 
    0     0 ACCEPT     udp  --  any    any     anywhere             anywhere            udp dpt:pop3 
   65  3538 ACCEPT     tcp  --  any    any     anywhere             anywhere            tcp dpt:pop3 
    0     0 ACCEPT     tcp  --  any    any     anywhere             anywhere            tcp dpt:26 
    0     0 ACCEPT     udp  --  any    any     anywhere             anywhere            udp dpt:26 
    0     0 ACCEPT     udp  --  any    any     anywhere             anywhere            udp dpt:pop3s 
 2355  184K ACCEPT     tcp  --  any    any     anywhere             anywhere            tcp dpt:pop3s 

Logs
Nothing adds to my /var/log/mail.log when I should receive other domains mail, but it seems ok when I try to receive mails by mail clients.

Apr 14 07:53:51 hostname dovecot: pop3-login: Login: user=<[email protected]>, method=PLAIN, rip=94.182.127.182, lip=178.79.152.29, TLS
Apr 14 07:53:52 hostname dovecot: POP3([email protected]): Disconnected: Logged out top=0/0, retr=0/0, del=0/7, size=6546

Nothing happens to /home/vmail/dovecot-deliver.log when I sould receive mail from other domains but in case of same domain email seems normal:

2011-04-14 05:42:53 deliver([email protected]): Info: msgid=<[email protected]>: saved mail to INBOX

I checked mail by VMail, mutt, Apple Mail and Thunderbird and it's my settings on mail clients:
Account Type: pop3
Incoming Mail Server: mail.mydomain.com
Username: [email protected]
Password: XXXXX
Outgoing Mail Server:
Server Name: mail.mydomain.com
Port: 2525
Use SSL
Authenitocation: Password
Username: [email protected]
Password: XXXXX

3
  • Can you add output from /var/log/maillog for smtp (#grep smtp /var/log/maillog) ? And is mydomain.com setup in the mysql virtualmap as a destination?
    – wrmine
    Apr 14, 2011 at 21:27
  • Yes in my domains in mysql are: mydomain.com and mail.mydomain.com (BTW I received Mail Deliver Alert, i added its detail to the question) Apr 14, 2011 at 21:56
  • #grep smtp /var/log/maillog: Apr 14 17:11:31 zooey postfix/smtpd[20460]: connect from unknown[(my public ip on my machine)]' Apr 14 17:11:32 zooey postfix/smtpd[20460]: disconnect from unknown[my public ip on my machine] Apr 14 17:18:17 zooey postfix/smtpd[20482]: warning: (my public ip on my machine): hostname (my public ip on my machine).(myisp) verification failed: Name or service not known Apr 14, 2011 at 22:02

2 Answers 2

1

Since absolutely nothing is logged in your /var/mail/mail.log and your chains show zero traffic coming in to tcp/25, I believe your ISP is blocking incoming traffic on tcp/25. This is normal practice for home users. Unless you have a business class connection, ISPs do not allow traffic to their customers destined for tcp/25.

You'll need some type of external service like DynDNS' mailhop. You set DynDNS up as your MX and they relay the mail to your server on an open destination port like 2525.

EDIT: to be clear; real internet email only ever travels on port tcp/25. You can't just open a port like 2525 and expect it to work.

3
  • Yes, my ISP blocked tcp/25 and as I mentioned I change default 25 port to 2525, I set it in my mail clients too and I don't have problem for outgoing mails. (BTW I received Mail Deliver Alert, i added its detail to the question) Apr 14, 2011 at 21:53
  • So why I when I use 2525 port, I'm able to send emails but can't receive emails?! Apr 14, 2011 at 22:30
  • Sending is different than receiving. It's outgoing traffic, not incoming. Likely that your ISP doesn't block outgoing mail on 25/tcp (so people can send through other services) and you can probably even use their mail server as a relay.
    – Sean C.
    Apr 15, 2011 at 1:30
1

Because my ISP is also blocking port 25, I added another port (2525) to /etc/postfix/main.cf. However, I made the mistake of commenting out the smtp port, resulting in a failure of receiving mails from external domains.

# Does not work
#smtp      inet  n       -       -       -       -       smtpd
2525      inet  n       -       -       -       -       smtpd

To receive mail from other servers, as well as circumvent the port restrictions of your ISP, simply open port 25 (smtp) and another port of your choosing.

# Works
smtp      inet  n       -       -       -       -       smtpd
2525      inet  n       -       -       -       -       smtpd
1
  • I don't have enough rep to voteup trembl comment, but I would like to thank him for his comment. Spent a week trying to debug a mailserver that wasn't receiving emails, and it was that simple mistake of commenting the smtp entry on master.cf
    – user180360
    Jul 4, 2013 at 17:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .