Centos – SendMail not working in CentOs 6.4

centossendmailsmtp

I am trying to send e-mails from my CentOS 6.4 but it does not work. My knowledge about servers is quite limited, so I hope someone can help me. Here is what I did:

  1. First i tried to send an email using the "mail" command, but it was not in the OS so I installed it.

    # yum install mailx
    
  2. After that, I tried sending an email using the "mail" command, but it did not send anything. I checked it on the internet and I realized I needed an e-mail server like sendmail, so I installed it.

    # yum install sendmail sendmail-cf sendmail-doc sendmail-devel
    
  3. After that, I configured it following some tutorials. First, sendmail.mc file.

    # vi /etc/mail/sendmail.mc
    
  4. Commented out the next line:

    BEFORE
    # DAEMON_OPTIONS('Port=smtp, Name=MTA') dnl
    
    AFTER
    # dnl DAEMON_OPTIONS('Port=smtp, Name=MTA') dnl
    
  5. Check that the next lines are correct:

    # FEATURE(`virtusertable', `hash -o /etc/mail/virtusertable.db')dnl
    # ...
    # FEATURE(use_cw_file)dnl
    # ...
    # FEATURE(`access_db', `hash -T<TMPF> -o /etc/mail/access.db')dnl
    
  6. Update sendmail.cf

    # m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
    
  7. Open the port 25 adding the proper line in the iptables file

    # vi /etc/sysconfig/iptables
    
    # -A INPUT -m state --state NEW -m tcp --dport 25 -j ACCEPT
    
  8. restart iptables and sendmail

    # service iptables restart
    # service sendmail restart
    

So i thought that would be ok, but when i tried:

    # mail 'test@gmail.com'
    # Subject: test subject
    # test content
    #.

I checked the mail log:

    # vi /var/log/maillog

And that is what I found:

    Aug 14 17:36:24 dev-admin-test sendmail[20682]: r7D8RItS019578: 
    to=<test@gmail.com>, ctladdr=<root@dev-admin-test.localdomain> (0/0), 
    delay=1+00:09:06, xdelay=00:00:00, mailer=esmtp, pri=2460500, relay=alt4.gmail-
    smtp-in.l.google.com., dsn=4.0.0, stat=Deferred: Connection timed out with 
    alt4.gmail-smtp-in.l.google.com.

I do not understand why there is a connection time out. Am I missing something? Can anyone help me, please?

Thank you.

Best Answer

Outgoing SMTP connections blocked by a firewall

Are you sure your outgoing SMTP connections are not blocked by a firewall?
It is a common outgoing spam precaution.

Do you get SMTP greeting message when you telnet port 25 and 587 on smtp.gmail.com?
[You should get the greeting at least on port 587]

telnet smtp.gmail.com 587
telnet smtp.gmail.com 25
Related Topic