Solved

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

Posted on 2014-02-20
3
1,331 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 110

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

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.  …
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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 …

726 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