I'm using sendEmail to send emails using google account .. it is working fine on number of identical servers but on one if the servers it gives me the following error

smtp.gmail.com:587 failed: IO::Socket::INET: connect: Connection refused

i also tried ssmtp but i also received a similar socket error

any ideas?

  • Sounds like a networking issue... Are you able to ping and telnet to the server i.e. ping smtp.gmail.com ; telnet smtp.gmail.com 587? – drone.ah Jan 17 '13 at 21:27

Have you tested you can reach the server from the box e.g.

$ ping  smtp.gmail.com
64 bytes from wi-in-f108.1e100.net ( icmp_seq=1 ttl=48 time=26.9 ms
64 bytes from wi-in-f108.1e100.net ( icmp_seq=2 ttl=48 time=27.0 ms

$ telnet smtp.gmail.com 587

Connected to smtp.gmail.com.
Escape character is '^]'.
220 mx.google.com ESMTP hg17sm2838358wib.1 - gsmtp
telnet> quit

Press CTRL+] and type quit to exit.

If not check you local firewall.

  • I'm able to ping but the connection is refused when i telnet .... i have another server in the same location that i can communicate normally so i guess the problem is related to this specific server socket – BluesRhythm Jan 18 '13 at 15:06
  • What do you get from a: sudo "iptables -L -n" – arober11 Jan 18 '13 at 15:15
  • Also read the following two questions 1, 2 – arober11 Jan 18 '13 at 15:25
  • Actually this is a firewall with shorewall installed, what i reached now is shorewall is rejecting the connection from the server to the smtp.gmail.com and here is the log ... however how can i modify this and configure shorewall to accept? Shorewall:fw2net:REJECT:IN= OUT=eth0 SRC=X.X.X.X DST= LEN=60 TOS=0x00 PREC=0x00 TTL=64 ID=43820 DF PROTO=TCP SPT=58025 DPT=587 WINDOW=5840 RES=0x00 SYN URGP=0 – BluesRhythm Jan 18 '13 at 17:54
  • By adding a series of accept rules to the /etc/shorewall/ config e.g. ACCEPT loc tcp 587 ACCEPT $FW tcp 587 – arober11 Jan 19 '13 at 7:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.