connect to smtp.gmail: Connection refused

Discussion in 'Server Operation' started by bhawna gupta, Mar 18, 2016.

  1. bhawna gupta

    bhawna gupta New Member

    Hi All,

    I am trying to send mail via Ubuntu 1404 version to my gmail ID. Ubuntu is running via VMware on my Windows machine. Please let me know if the above description is not clear as I am newbie in working with virtual machine.

    I am trying to run the below command:
    Code:
    echo "This is the body of the email" | mail -s "This is the subject line" myemailID
    There is no error prompt. I have already executed the following utilities on ubuntu
    Code:
    sudo apt-get install mailutils
    sudo apt-get install postfix mailutils libsasl2-2 ca-certificates libsasl2-modules
    sudo dpkg-reconfigure postfix
    
    I have selected 'Internet site' as mail configuration and rest settings as default. I have checked mail.log file by executing 'tail -f /var/log/mail.log' and following is the message:
    Code:
    Mar 17 16:22:27 ubuntu postfix/qmgr[8503]: 47063105856: from=<>, size=474, nrcpt=1 (queue active)
    Mar 17 16:22:27 ubuntu postfix/pickup[8502]: 4FF51105857: uid=1000 from=<>
    Mar 17 16:22:27 ubuntu postfix/cleanup[8505]: 4FF51105857: message-id=<20160317105227.4FF51105857>
    Mar 17 16:22:27 ubuntu postfix/qmgr[8503]: 4FF51105857: from=<>, size=476, nrcpt=1 (queue active)
    Mar 17 16:22:27 ubuntu postfix/smtp[8508]: connect to smtp.gmail.com[64.233.176.109]:587: Connection refused
    Mar 17 16:22:27 ubuntu postfix/smtp[8508]: connect to smtp.gmail.com[64.233.176.108]:587: Connection refused
    Mar 17 16:22:27 ubuntu postfix/smtp[8508]: 47063105856: to=<myemailid>, relay=none, delay=0.08, delays=0.03/0/0.05/0, dsn=4.4.1, status=deferred (connect to smtp.gmail.com[64.233.176.108]:587: Connection refused)
    Mar 17 16:22:27 ubuntu postfix/smtp[8541]: connect to smtp.gmail.com[64.233.176.109]:587: Connection refused
    Mar 17 16:22:27 ubuntu postfix/smtp[8541]: connect to smtp.gmail.com[64.233.176.108]:587: Connection refused
    Mar 17 16:22:27 ubuntu postfix/smtp[8541]: 4FF51105857: to=<myemailid>, relay=none, delay=0.06, delays=0/0.01/0.05/0, dsn=4.4.1, status=deferred (connect to smtp.gmail.com[64.233.176.108]:587: Connection refused)
    /etc/postfix/main.cf file is also attached for reference. Please guide and let me know if any other information is required.

    Thanks,
    Bhawna
     

    Attached Files:

  2. ztk.me

    ztk.me ISPConfig Developer ISPConfig Developer

    You can compare to the configuration in this thread.
    Connection refused however does look bad, have you some kind of firewall running which is preventing outgoing connections?
    What kind of network setup are you using within vmware?
     
  3. bhawna gupta

    bhawna gupta New Member

    Thanks for the reply.
    Pardon my ignorance, but how can I check for the network setup within VMware.
    As I mentioned I have Ubuntu running on VMware and Windows Firewall is turned on. Attached is the screenshot for reference.
    I also referred the thread link, but I understand in that thread issue is sending emails via GMAIL SMTP, I don't have any condition like that. I am fine with sending the email from Ubuntu/GMAIL/Anything
     

    Attached Files:

  4. florian030

    florian030 ISPConfig Developer ISPConfig Developer

    Try to use port 25 instead of 587
     
  5. bhawna gupta

    bhawna gupta New Member

    hi, I tried updating settings in main.cf file for relayhost to below but it didn't work:

    Code:
    relayhost = [smtp.gmail.com]:25
     
  6. florian030

    florian030 ISPConfig Developer ISPConfig Developer

    Connection refused is quite clear. Can you run connect using telnet?
    telnet 64.233.176.108 25
    telnet 64.233.176.108 587
    ?
    Is there any reason why you use [..]? I think, you can relay to gmail using the MX-Records.
     
  7. bhawna gupta

    bhawna gupta New Member

    This is output received:

    Code:
    ubuntu:~/Desktop$ telnet 64.233.176.108 25
    Trying 64.233.176.108...
    telnet: Unable to connect to remote host: Connection refused
    ubuntu:~/Desktop$ telnet 64.233.176.108 587
    Trying 64.233.176.108...
    telnet: Unable to connect to remote host: Connection refused
    
    Also tried removing square brackets around relayhost variable. No mail received on my gmail ID
     
  8. ztk.me

    ztk.me ISPConfig Developer ISPConfig Developer

    right click your virtual machine, go to Settings > Network > Adapter 1
    It should be enabled, attachted to your hosts network adapter you're using to connect to the internet as a bridged adapter.
    587 is perfectly right for gmail.

    It's kinda interesting you were able to install packages on ubuntu while you can't do a simple mail delivery to gmail :/
    Have you installed everything from cd images?
     
  9. bhawna gupta

    bhawna gupta New Member

    I have tried changing the Virtual machine settings from NAT to Bridged. But still no results. Attached is snapshot for reference.
    Also I had first installed VMware Workstation 12 Player. Then downloaded ubuntu-14.04.4-desktop-amd64.iso and created a virtual machine for it.

    Kindly let me know if any other information is required.

    Thanks in advance.
     

    Attached Files:

  10. ztk.me

    ztk.me ISPConfig Developer ISPConfig Developer

    Can you telnet from your windows machine?
    Enter this in a windows command line prompt
    Code:
    telnet 64.233.176.108 587
    
    
     
  11. bhawna gupta

    bhawna gupta New Member

    I receive the below message:

    Code:
    telnet 64.233.176.108 587
    Trying 64.233.176.108...
    telnet: Unable to connect to remote host: Network is unreachable
    
     
  12. ztk.me

    ztk.me ISPConfig Developer ISPConfig Developer

    Check your firewall if you block outgoing connections on port 587 then, no issue obviously with your VM settings or linux inside it.
     
  13. bhawna gupta

    bhawna gupta New Member

    Thanks for the help... I deleted Ubuntu virtual machine and re-created it. It is now able to send mails to gmail. Thanks a lot:) What I am trying now is to send email to my yahoo and office ID, which is not working. Any pointers are appreciated.
     
  14. ztk.me

    ztk.me ISPConfig Developer ISPConfig Developer

Share This Page