Why I can't send mail to remote mailbox?

14,006

Solution 1

The first thing to do in case of SMTP problems where the configuration seems to be OK is that you can actually reach the SMTP server.

Use:

telnet gmail-smtp-in.l.google.com 25

you should see:

Trying 173.194.69.27...
Connected to gmail-smtp-in.l.google.com.
Escape character is '^]'.
220 mx.google.com ESMTP lv5si9142984bkb.114 - gsmtp

(after that type QUITEnter to exit) If that doesn't show up your firewall (or more likely the one of your provider) might be blocking you. Try this from another location if possible to double check the machine is responding (in your case gmail-smtp-in.l.google.com is responding).

If the provider is the cause, you may need to use its STMP server (they attempt to prevent spam going out from your system this way).

Solution 2

Try to change inet_protocol option in postfix settings. Go to /etc/postfix/main.cf and change from:

inet_protocols = all

to:

inet_protocols = ipv4

Then

service postfix reload
service postfix flush
Share:
14,006

Related videos on Youtube

ludiegu
Author by

ludiegu

BOFH.

Updated on September 18, 2022

Comments

  • ludiegu
    ludiegu over 1 year

    I have installed Postfix on my CentOS machine. I can nicely send mails to local accounts with mutt, but when I try to send one to a remote mail like [email protected], I cannot understand why I can't receive anything. Here my main.cf:

    queue_directory = /var/spool/postfix
    command_directory = /usr/sbin
    daemon_directory = /usr/libexec/postfix
    data_directory = /var/lib/postfix
    mail_owner = postfix
    myhostname = server.example.com
    mydomain = example.com
    myorigin = $mydomain
    inet_interfaces = all
    inet_protocols = all
    mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
    unknown_local_recipient_reject_code = 550
    mynetworks = 192.168.200.0/24, 127.0.0.0/8
    alias_maps = hash:/etc/aliases
    alias_database = hash:/etc/aliases
    debug_peer_level = 2
    debugger_command =
         PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
         ddd $daemon_directory/$process_name $process_id & sleep 5
    
    
    sendmail_path = /usr/sbin/sendmail.postfix
    newaliases_path = /usr/bin/newaliases.postfix
    mailq_path = /usr/bin/mailq.postfix
    setgid_group = postdrop
    html_directory = no
    manpage_directory = /usr/share/man
    sample_directory = /usr/share/doc/postfix-2.6.6/samples
    readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
    

    In the maillog I find these:

    Jan 22 14:33:15 server postfix/qmgr[5025]: 316FEBF65E: from=<[email protected]>, size=430, nrcpt=1 (queue active)
    Jan 22 14:33:15 server postfix/smtp[5276]: connect to gmail-smtp-in.l.google.com[2a00:1450:400c:c05::1b]:25: Network is unreachable
    Jan 22 14:33:15 server postfix/smtp[5276]: connect to gmail-smtp-in.l.google.com[173.194.66.26]:25: Connection refused
    Jan 22 14:33:15 server postfix/smtp[5276]: connect to alt1.gmail-smtp-in.l.google.com[2a00:1450:400c:c05::1a]:25: Network is unreachable
    Jan 22 14:33:15 server postfix/smtp[5276]: connect to alt1.gmail-smtp-in.l.google.com[173.194.70.26]:25: Connection refused
    Jan 22 14:33:15 server postfix/smtp[5276]: connect to alt2.gmail-smtp-in.l.google.com[2a00:1450:400c:c05::1b]:25: Network is unreachable
    Jan 22 14:33:15 server postfix/smtp[5276]: 316FEBF65E: to=<[email protected]>, relay=none, delay=2662, delays=2661/0.04/0.08/0, dsn=4.4.1, status=deferred (connect to alt2.gmail-smtp-in.l.google.com[2a00:1450:400c:c05::1b]:25: Network is unreachable)
    

    But I can ping nicely the host:

    ping gmail-smtp-in.l.google.com
    PING gmail-smtp-in.l.google.com (173.194.66.26) 56(84) bytes of data.
    64 bytes from we-in-f26.1e100.net (173.194.66.26): icmp_seq=1 ttl=128 time=29.2 ms
    64 bytes from we-in-f26.1e100.net (173.194.66.26): icmp_seq=2 ttl=128 time=29.6 ms
    64 bytes from we-in-f26.1e100.net (173.194.66.26): icmp_seq=3 ttl=128 time=31.0 ms
    
    • Admin
      Admin over 10 years
      What does your mail log say?
    • Admin
      Admin over 10 years
      Edited the question.
    • Admin
      Admin over 10 years
      Your ISP is probably blocking port 25.
    • Admin
      Admin over 10 years
      yes, do a telnet gmail-smtp-in.l.google.com 25 to test. You want to see "Connected". I describe it here: linuxintro.org/wiki/Set_up_your_mail_server_for_sending#Test‌​_it
    • Admin
      Admin over 10 years
      can you run nmap to see if the ports are reachable? nmap gmail-smtp-in.l.google.com Are you behind a router/firewall?
    • Admin
      Admin over 10 years
      As @jordanm said, the ISP was blocking the port 25. Another story is that my Postfix cannot sent a mail to my gmail account because theri smtp blocked it.
    • Admin
      Admin over 10 years
      @jordanm or ludiegu: please post this as an answer, it's a common problem.
  • mleonard
    mleonard over 8 years
    This won't fix the problem of the OP. The logs clearly show that the connection is refused on IPv4.
  • Sridhar Sarnobat
    Sridhar Sarnobat over 7 years
    I found that from my office network the telnet worked but from my home network didn't (using the above command). When I changed it to telnet smtp.gmail.com 465 it worked from my home network.
  • jchook
    jchook over 7 years
    Thanks man this helped a lot. I used a VPN service to bypass the block from my ISP.