Solved

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

Posted on 2014-02-20
3
1,303 Views
Last Modified: 2014-02-27
Hi,

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) )
    {
        break;
    }
}

Open in new window

0
Comment
Question by:mhdi
  • 2
3 Comments
 
LVL 109

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
0
 

Accepted Solution

by:
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
0
 

Author Closing Comment

by:mhdi
ID: 39891402
Hosting provider issue found.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

808 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