PHP - fsocket connections failing (time out), not sure why...

Posted on 2014-02-20
Medium Priority
Last Modified: 2014-02-27

I am attempting to deliver emails directly by connecting to my recipients smtp server.

However when the script tries to connect to googles mail servers it times out. Can anyone see why?

Warning: fsockopen() [function.fsockopen]: unable to connect to alt2.aspmx.l.google.com:25 (Connection timed out) in /smtpSend.php on line 89

Warning: fsockopen() [function.fsockopen]: unable to connect to alt3.aspmx.l.google.com:25 (Connection timed out) in /smtpSend.php on line 89

Warning: fsockopen() [function.fsockopen]: unable to connect to alt4.aspmx.l.google.com:25 (Connection timed out) in /smtpSend.php on line 89

Warning: fsockopen() [function.fsockopen]: unable to connect to aspmx.l.google.com:25 (Connection timed out) in /smtpSend.php on line 89

Warning: fsockopen() [function.fsockopen]: unable to connect to alt1.aspmx.l.google.com:25 (Connection timed out) in /smtpSend.php on line 89

Open in new window

array(2) { ["mx"]=> array(5) { [0]=> string(23) "alt2.aspmx.l.google.com" [1]=> string(23) "alt3.aspmx.l.google.com" [2]=> string(23) "alt4.aspmx.l.google.com" [3]=> string(18) "aspmx.l.google.com" [4]=> string(23) "alt1.aspmx.l.google.com" } ["weight"]=> array(5) { [0]=> int(30) [1]=> int(40) [2]=> int(50) [3]=> int(10) [4]=> int(20) } } 

Open in new window

foreach($mxhosts['mx'] as $smtp_host){
    if($socket = fsockopen($smtp_host, 25, $errno, $errstr, 20) )

Open in new window

Question by:mhdi
  • 2
LVL 111

Expert Comment

by:Ray Paseur
ID: 39876558
Where are Google's instructions that tell how to connect to its mail servers?  Can you post a link for us?  Thanks, ~Ray

Accepted Solution

mhdi earned 0 total points
ID: 39880199
I found the issue. It was my hosting providers firewall blocking outbound connections initiated by PHP on port 25

Author Closing Comment

ID: 39891402
Hosting provider issue found.

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

These days socially coordinated efforts have turned into a critical requirement for enterprises.
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

586 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question