Postfix : Connect to smtp.gmail.com[173.194.70.108]:587: Connection timed out

12
2013-08
  • Osama Jaber

    I was setting up Postfix on (Ubuntu 12.10). This is my main.cf file content :

        smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
        biff = no
        append_dot_mydomain = no
        readme_directory = no
        # TLS parameters
        smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
        smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.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  
        myhostname = osamaHP
        alias_maps = hash:/etc/aliases
        alias_database = hash:/etc/aliases
        myorigin = /etc/mailname
        mydestination = ubuntu.localhost, localhost.localdomain
        relayhost = [smtp.gmail.com]:587
        mailbox_size_limit = 0
        recipient_delimiter = +
        inet_interfaces = all
        inet_protocols = all
        mynetworks = 127.0.0.0/8 xxx.16.0.0/24 [::1]/128 xxx.16.0.101
        proxy_interfaces = xxx.16.0.1
        smtp_sasl_auth_enable = yes
        smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
        smtp_sasl_security_options = noanonymous
        smtp_tls_CAdile = /etc/ssl/certs/Equifax_Secure_CA.pem
    

    When I tried to send an email

    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>
    TestTestTest
    .
    250 2.0.0 Ok: queued as 320DB223C63
    

    this is my mail.log file

    Jun 23 14:39:30 osamaHP postfix/smtp[11766]: 320DB223C63: to=<[email protected]>, relay=none, delay=91, delays=31/0.01/60/0, dsn=4.4.1, status=deferred (connect to smtp.gmail.com[173.194.70.109]:587: Connection timed out)
    Jun 23 14:39:45 osamaHP postfix/smtp[11791]: connect to smtp.gmail.com[173.194.70.108]:587: Connection timed out
    Jun 23 14:39:45 osamaHP postfix/smtp[11791]: 7F6F6223AA2: to=<[email protected]>, relay=none, delay=4610, delays=4549/0.01/60/0, dsn=4.4.1, status=deferred (connect to smtp.gmail.com[173.194.70.108]:587: Connection timed out)
    

    Notes: - Port 25 is not blocked by ISP - When I used port 465 , I got this log

    Jun 23 20:09:16 osamaHP postfix/smtpd[4881]: E7A3622385D: client=unknown[192.168.1.13]
    Jun 23 20:09:23 osamaHP postfix/cleanup[4885]: E7A3622385D: message-id=<20130623170916.E7A3622385D@osamaHP>
    Jun 23 20:09:23 osamaHP postfix/qmgr[4878]: E7A3622385D: from=<[email protected]>, size=296, nrcpt=1 (queue active)
    Jun 23 20:09:23 osamaHP postfix/smtp[4886]: CLIENT wrappermode (port smtps/465) is unimplemented
    Jun 23 20:09:23 osamaHP postfix/smtp[4886]: instead, send to (port submission/587) with STARTTLS
    

    then I changed it to port 587 and I used STARTTLS, then I got

    Jun 23 20:25:23 osamaHP postfix/smtpd[5311]: connect from unknown[192.168.1.13]
    Jun 23 20:25:49 osamaHP postfix/smtpd[5311]: SSL_accept error from unknown[192.168.1.13]: -1
    Jun 23 20:25:49 osamaHP postfix/smtpd[5311]: warning: TLS library problem: 5311:error:140760FC:SSL routines:SSL23_GET_CLIENT_HELLO:unknown protocol:s23_srvr.c:628:
    Jun 23 20:25:49 osamaHP postfix/smtpd[5311]: lost connection after STARTTLS from unknown[192.168.1.13]
    Jun 23 20:25:49 osamaHP postfix/smtpd[5311]: disconnect from unknown[192.168.1.13]
    

    Does anybody have an idea about what happens here ?

  • Answers
    Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

    Related Question

    osx - How do I configure the built-in Postfix on Mac OS X to not connect directly to destination hosts other than itself?
  • Kevin Reid

    I run cron jobs on my Mac laptop, and so I want the mail daemon to be able to send the output mail to my regular mail account. I've got that working (my local account has a .forward file), but I'm often on networks where connecting to the destination's MX on port 25 doesn't succeed.

    Therefore, I would like to have the local mail daemon send its outgoing mail, regardless of the destination, to another SMTP server (which happens to be a SSH port-forward to a server under my control). How do I configure the Apple-supplied Postfix to do this?

    Update:

    I tried setting relayhost = [localhost]:40125 (where 40125 is the SSH port forward), but while I can now send mail to a proper Internet mail address (e.g. [email protected]), cron job mail (which is addressed to kpreid@<whatever the DHCP hostname is>) doesn't get delivered. From the one bounce I saw, it appears that this causes all mail, even for the local hostname, to go to the relayhost first.

    Therefore, I need a way to relay to [localhost]:40125 unless the address domain is this machine's domain (which varies frequently).


  • Related Answers
  • JanC

    You need to set the relayhost directive in /etc/postfix/main.cf (and maybe tweak some other settings, but that's hard to say without knowing the default config from Apple).